正在加载图片...
for(i=0; K<M; i ++) for=0;j<M; j++) printf( %d "a[GD: f==j(i+j)==(M-1)sum2=sm2+a]; f(i==0i==(M-1川|i==0|==(M-1) suml=sum1+a[G] printf( \n) printf "\nThe round sum is %d"); printf( "\nThe corner sum is %d"sum2) (11)有一段文字,共有5行,分别统计出其中英文大写字母、小写字母、数字、 空格以及其它字符的个数 #indlude"string. h char a[5 [100] int i,j=O, alpha=0, lalpha=0, number=0, space=0, other=0; printf( "iNput 5 string: \n"); for(i=0<5;i++) gets(a[D for(i=0;<5;++) ualpha=0; lalpha=0; number=0; space=0 other=0 forj=0j<100j++) if(a[[]!="0) f(a[>=65&&aJ]<=90) alpha++; else if(a[0]>=97&&a[0]<=122) lalpha++ else if(a[[]>=48&&a[0]<=57)number++i else if(a[G]==32) space++ else other++ else break. printf("n%d: alpha: %d, lalpha: %d, number: %d space: %d, other: %d",i, ualpha lalpha, number, space, other);for(i=0;i<M;i++) { for(j=0;j<M;j++) { printf("%d ",a[i][j]); if(i==j||(i+j)==(M-1)) sum2=sum2+a[i][j]; if(i==0||i==(M-1)||j==0||j==(M-1)) sum1=sum1+a[i][j]; } printf("\n"); } printf("\nThe round sum is %d",sum1); printf("\nThe corner sum is %d",sum2); } (11) 有一段文字,共有 5 行,分别统计出其中英文大写字母、小写字母、数字、 空格以及其它字符的个数。 #include "string.h" main() { char a[5][100]; int i,j=0,ualpha=0,lalpha=0,number=0,space=0,other=0; printf("\nInput 5 string:\n"); for(i=0;i<5;i++) gets(a[i]); for(i=0;i<5;i++) { ualpha=0;lalpha=0;number=0;space=0;other=0; for(j=0;j<100;j++) { if(a[i][j]!='\0') { if(a[i][j]>=65&&a[i][j]<=90) ualpha++; else if(a[i][j]>=97&&a[i][j]<=122) lalpha++; else if(a[i][j]>=48&&a[i][j]<=57) number++; else if(a[i][j]==32) space++; else other++; } else break; } printf("\n%d:ualpha:%d,lalpha:%d,number:%d,space:%d,other:%d",i,ualpha ,lalpha,number,space,other); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有