C++ day1

1.xmind

2.
 

#include 

using namespace std;

int main()
{
    cout << "please enter " << endl;
    string str1;
    getline(cin,str1);
    int daxie,xiaoxie,shuzi,kong,other;
    daxie=xiaoxie=shuzi=kong=other=0;
    for(unsigned int i=0;i='A' && str1.at(i)<='Z')
            daxie++;
        else if(str1.at(i)>='a' && str1.at(i)<='z')
            xiaoxie++;
        else if(str1.at(i)>='0' && str1.at(i)<='9')
            shuzi++;
        else if(str1.at(i)== ' ')
            kong++;
        else 
            other++;             
    }
    cout << "大写字母个数:" << daxie << endl; 
    cout << "小写字母个数:" <<  xiaoxie << endl;
    cout << "数字个数:" <<  shuzi << endl;
    cout << "空个数:" <<  kong << endl;
    cout << "其他字符个数:" <<  other << endl;
    return 0;
}

你可能感兴趣的:(c++,算法,开发语言)