Run ID:93543
提交时间:2024-10-17 20:08:14
//1055 大写转小写 #include <stdio.h> #include <ctype.h> #include <string.h> #define MAX_LENGTH 1000 main() { char sentence[MAX_LENGTH + 1]; fgets(sentence, sizeof(sentence), stdin); int nums=0,letters=0; int spaces =0; int others =0; int n = strlen(sentence); for(int i=0;sentence[i] != '\n';i++) { if(isdigit(sentence[i])) { nums++; } else if(isalpha(sentence[i])) { letters++; } else if ( sentence[i]==' ') { spaces++; } else { others++; //printf("-%c-%d*",sentence[i],i); } } printf("%d %d %d %d\n",letters,spaces,nums,others); return 0; } /* Input What are you doing? 123456 Output 15 4 6 1 */