“*”菱形打印程序
0赞
发表于 2013/8/14 11:07:38
阅读(1102)
闲来无事,还记得以前课本上的那个课后习题,那就编个小程序玩玩。
1 //date:2013/8/14 2 //designer :pengxiaoen 3 //function: just for fun 4 5 #include "stdio.h" 6 #include "math.h" 7 int main () 8 { 9 int i,j,k,r;10 int t,temp1,temp2;11 //------------------------------------------------------------- 12 printf ("please enter a odd number between 3 and 30 : ");13 scanf("%d",&r);14 while ((r<3) || (r>30) || ((r+1)%2) )15 {16 printf("\n error \n\n");17 printf ("please enter a odd number between 3 and 30 : ");18 scanf("%d",&r);19 }20 21 t = (r-1)/2;22 temp1 = t+1;23 //-------------------------------------------------------------- 24 for(i=0; i
执行结果