标签:
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 5 void graph(int num); 6 void graph2(int num); 7 int main(int argc, char *argv[]) { 8 9 10 int num; 11 scanf("%d",&num); 12 graph(num); 13 graph2(num); 14 15 return 0; 16 } 17 18 void graph(int num){ 19 int i; 20 for(i=1;i<=num;i++){ 21 int j=1; 22 while(j<=(num-i)){ 23 24 printf(" "); 25 j++; 26 } 27 int k=1; 28 while(k<=(2*i-1)){ 29 printf("*"); 30 k++; 31 } 32 33 int m=1; 34 while(m<=(num-i)){ 35 36 printf(" "); 37 m++; 38 } 39 printf("\n"); 40 } 41 42 } 43 44 void graph2(int num){ 45 int i; 46 47 48 for(i=1;i<num;i++){ 49 int j=1; 50 while(j<=i){ 51 printf(" "); 52 j++; 53 } 54 55 int k=1; 56 while(k<=2*num-1-2*i){ 57 printf("*"); 58 k++; 59 } 60 int m=1; 61 while(m<=i){ 62 printf(" "); 63 m++; 64 } 65 66 printf("\n"); 67 } 68 69 }
标签:
原文地址:http://www.cnblogs.com/wpzy2311/p/4980792.html