• 2022-06-06
    有一篇文章,共有3行文字,每行有80个字符。要求分别统计出其中英文大写字母、小写字母、数字、空格以及其他字符的个数。
  • #include<iostream>using namespace std;int main(){ int i,j,upper,lower,digit,space,other; char text[3][80]; upper=lower=digit=space=other=0; for(i=0; i<3; i++) { cout<<"please input line"<<i+1<<endl; gets(text[i]); for(j=0; j<80&&text[i][j]!='\0'; j++) { if(text[i][j]>='A'&&text[i][j]<='Z') upper++; else if(text[i][j]>='a'&&text[i][j]<='z') lower++; else if(text[i][j]>='0'&&text[i][j]<='9') digit++; else if(text[i][j]==' ') space++; else other++; } } cout<<"upper case:"<<upper<<endl; cout<<"lower case:"<<lower<<endl; cout<<"digit :"<<digit<<endl; cout<<"space :"<<space<<endl; return 0;}[/i][/i][/i][/i][/i][/i][/i][/i][/i]

    内容

    • 0

      一篇文章有3行文字,每行80个字符,分别统计其中大小写英文字母、空格、数字和其他字符的个数。

    • 1

      1.字符统计有一行文字(不超过80个字符),要求分别统计出其中英文大写字母、小写字母、数字、空格及其他字符的个数并输出。

    • 2

      从键盘输入一篇英文学术文章的标题,要求不多于40个字符,分别统计其中大写字母、小写字母、数字和其他字符的个数。

    • 3

      统计英文文本文件中,有多少个大写字母、小写字母、数字、空格、换行以及其他字符

    • 4

      输入一行文字, 统计其中的大写字母、小写字母、空格、数字以及其他字符各有多少?