输入字符串以及输出

来源:互联网 发布:战舰世界炮弹数据 编辑:程序博客网 时间:2024/06/06 01:51
#include <iostream>using namespace std;void  tongji(char str0[100],int  b[4]){int i;for(i=0;str0[i]!='\0';i++){if(str0[i]>='A'&&str0[i]<='Z'||str0[i]>='a'&&str0[i]<='z')b[0]++;else if(str0[i]>=48&&str0[i]<=57)b[1]++;else if(str0[i]==32)b[2]++;else b[3]++;}}int main(){    char str[100];    int i,a[4]={0};    cin.getline(str,99);    tongji(str,a);    for(i=0; i<4; i++)        cout<<a[i]<<" ";    cout<<endl;    return 0;}

输出结果:


0 0
原创粉丝点击