C++ day1

#include 
#include 

using namespace std;

int main()
{
   string str;
   getline(cin,str);
   cout << "str= " << str << endl;
   int count1,count2,count3,count4,count5;
   for(int i=0; i= 'A' && str(i) <= 'Z')
       {
           count1++;
           break;
       }

       else if(str.at(i) <= 'a' && str.at(i) >= 'z')
       {
           count2++;
           break;
       }
       else if(str.at(i) >= '1' && str.at(i) <= '127')
       {
           count3++;
           break;
       }
       else if(str.at(i) = ' ')
       {
           count4++;
           break;
       }
       else
       {
           count5++;
           break;
       }
   }
   cout << "大写字母个数count1= " << count1 << endl;
   cout << "小写字母个数count2= " << count2 << endl;
   cout << "数字个数count3= " << count3 << endl;
   cout << "空格个数count4= " << count4 << endl;
   cout << "其他字符个数count5= " << count5 << endl;
    return 0;
}

C++ day1_第1张图片

你可能感兴趣的:(c++)