[YTU]_1032( 统计出其中英文字母、数字、空格和其他字符的个数)
生活随笔
收集整理的這篇文章主要介紹了
[YTU]_1032( 统计出其中英文字母、数字、空格和其他字符的个数)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Description
輸入一行字符,分別統(tǒng)計(jì)出其中英文字母、數(shù)字、空格和其他字符的個(gè)數(shù)。
Input
一行字符
Output
統(tǒng)計(jì)值
Sample Input
aklsjflj123 sadf918u324 asdf91u32oasdf/.';123Sample Output
23 16 2 4 #include <iostream> #include <cstring> using namespace std; int main() {char str[101];int i,a=0,b=0,c=0,d=0;gets(str);for(i=0;str[i]!='\0';i++){if((str[i]>=65&&str[i]<=90)||(str[i]>=97&&str[i]<=122))a++;else if(str[i]>=48&&str[i]<=57)b++;else if(str[i]==' ')c++;elsed++;}cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;return 0; }總結(jié)
以上是生活随笔為你收集整理的[YTU]_1032( 统计出其中英文字母、数字、空格和其他字符的个数)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [YTU]_2800( 逗逗泡泡的保密电
- 下一篇: [YTU ]_2736指针练习--输出最