#include <stdio.h> int main(){ char ch; int letter_num=0; int blank_num=0; int digit_num=0; int other_num=0; int n; if (scanf("%d",&n)!=EOF){ getchar(); while (n>0){ // for(int j=0;j<n;j++){ if (scanf("%c",&ch)!=EOF){ n--; // if (j==0 && (ch==' '||ch=='\n')){continue;j--;} if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')){ letter_num++;} else if(ch >= '0' && ch <= '9'){ digit_num++; } else if(ch==' '||ch == '\n'){ blank_num++; }else{ other_num++; } // printf("n=%d ch=%c letter = %d, blank = %d, digit = %d, other = %d\n",n,ch,letter_num,blank_num,digit_num,other_num); } } printf("letter = %d, blank = %d, digit = %d, other = %d",letter_num,blank_num,digit_num,other_num); } return 0; }
c语言编程练习题:7-187 统计字符[2]
作者:yunjinqi
类别:编程
日期:2023-06-04 18:50:16
阅读:601 次
消耗积分:0 分
版权所有,转载本站文章请注明出处:云子量化, https://www.yunjinqi.top/article/311
最新文章
系统当前共有 442 篇文章