吴鹏的博客
1.输出以下图案
2. 输出以下图案
3.输出以下图案
Tags: c, 调试程序 Views:1555
C
Comments
4/14/2008 4:09:22 AM #
1.#include <stdio.h>void main(){ int i,j; int n; printf("Input The Total Line Of The Square:"); scanf("%d",&n); printf("\n\n"); for(i=1;i<=n;i++) { for(j=1;j<=2*n;j++) { printf("*"); } printf("\n"); } printf("\n");}2.#include <stdio.h>void main(){ int i,j; int n; printf("Input The Total Line Of The Square:"); scanf("%d",&n); printf("\n\n"); for(i=1;i<=n;i++) { if(i==1 || i==n) { for(j=1;j<=2*n;j++) { printf("*"); } } else { for(j=1;j<=2*n;j++) { if(j==1 || j==2*n) { printf("*"); } else { printf(" "); } } } printf("\n"); } printf("\n");}3.#include <stdio.h>void main(){ int i,j; int n,m=0; printf("Input The Total Line Of The Diamond.\n"); printf("It must be an odd:"); scanf("%d",&m); printf("\n\n"); n=m/2+1; for(i=1;i<=n;i++) { for(j=1;j<=n-i;j++) { printf(" "); } for(j=1;j<=(2*i-1);j++) { printf("*"); } printf("\n"); } for(i=1;i<=n-1;i++) { for(j=1;j<=i;j++) { printf(" "); } for(j=1;j<=(2*n-2*i-1);j++) { printf("*"); } printf("\n"); } printf("\n");}
吴鹏 |
Powered by BlogEngine.NET 1.5.0.7 Theme by Mads Kristensen 浙ICP备09023819号
1.男 2.已婚 3.网虫 4.宝宝叫yoyo