思維導圖
#include <iostream>using namespace std;int main()
{int a=0,b=0,c=0,d=0;string i;cout << "請輸入一個字符串" << endl;getline(cin,i);int y=i.size()-1;while(1){if('a'<=i[y]&&i[y]<='z'){a=a+1;}else if('A'<=i[y]&&i[y]<='Z'){b=b+1;}else if('0'<=i[y]&&i[y]<='9'){c=c+1;}else if(i[y]==' '){d=d+1;}y--;if(y==-1){cout << "小寫字母"<< a << "個" << endl;cout << "大寫字母"<< b << "個" << endl;cout << "數字"<< c << "個" << endl;cout << "空格"<< d << "個" << endl;return 0;}}return 0;
}