1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include <stdio.h> //Name:雷博闻 Student ID:11923040207 #include "string.h" int main(){ char zifu[3][80]={ "Its name might sound a little plain, but the grey-headed albatross is the most e", "Not only a majestic bird, the grey-headed albatross is a literal a world recoreq", "In 2003, The Guinness Book of Records gave them the title of world’s fastest h" }; int i=0,j=0,upper=0,lower=0,numbers=0,others=0; while (i<=2) {j=0; while (j<=79) { if((zifu[i][j]>='A')&&(zifu[i][j]<='Z')){ upper++; } else if ((zifu[i][j]>='a')&&(zifu[i][j]<='z')){ lower++; } else if ((zifu[i][j]>='0')&&(zifu[i][j]<='9')){ numbers++; } else{ others++; } j++; } i++; } printf("大写字母的个数是:%d\n小写字母的个数是:%d\n数字的个数是在:%d\n其他字符的个数是:%d\n",upper,lower,numbers,others); printf("%d\n",upper+lower+numbers+others); }
|