方法一:#include<stdio.h> int n;void draw(int n){int i,j;for (i=1-(n>>1);i<=n;i++) if (i>=0) { for (j=0;j<i;j++) printf(" "); for (j=1;j<=2*(n-i)+1;j++) printf(" *"); printf("\n"); } else { for (j=i;j<0;j++) printf(" "); for (j=1;j<=n+2*i+1;j++) printf(" *"); for (j=1;j<=-1-2*i;j++) printf(" "); for (j=1;j<=n+2*i+1;j++) printf(" *"); printf("\n"); }}int main() { printf("Please input the size (n>=4):"); scanf("%d",&n); draw(n);return 0; }
方法二:int a=DETECT,b;float r,R=9;float n=10*3.14/180,x,y;int i;initgraph(&a,&b,"");circle(200,300,R);for(i=0;i<36;i++){x=200+R*cos(i*n);y=300+R*sin(i*n);r=sqrt((x0-x)^2+(y0-y)^2);/*x0,y0為R圓上的一定點*/circle(x0,y0,r);}closegraph();
方法一:#include<stdio.h> int n;void draw(int n){int i,j;for (i=1-(n>>1);i<=n;i++) if (i>=0) { for (j=0;j<i;j++) printf(" "); for (j=1;j<=2*(n-i)+1;j++) printf(" *"); printf("\n"); } else { for (j=i;j<0;j++) printf(" "); for (j=1;j<=n+2*i+1;j++) printf(" *"); for (j=1;j<=-1-2*i;j++) printf(" "); for (j=1;j<=n+2*i+1;j++) printf(" *"); printf("\n"); }}int main() { printf("Please input the size (n>=4):"); scanf("%d",&n); draw(n);return 0; }
方法二:int a=DETECT,b;float r,R=9;float n=10*3.14/180,x,y;int i;initgraph(&a,&b,"");circle(200,300,R);for(i=0;i<36;i++){x=200+R*cos(i*n);y=300+R*sin(i*n);r=sqrt((x0-x)^2+(y0-y)^2);/*x0,y0為R圓上的一定點*/circle(x0,y0,r);}closegraph();