精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • c++輸入一行字符,分別統(tǒng)計出其中英文字母,空格,數(shù)字字符和其它字符的個數(shù).

    c++輸入一行字符,分別統(tǒng)計出其中英文字母,空格,數(shù)字字符和其它字符的個數(shù).
    用cin.get(c)函數(shù)從鍵盤上輸入一個字符給變量c,直到輸入回車換行字符'\n'為止.
    其他人氣:716 ℃時間:2020-05-10 13:32:38
    優(yōu)質(zhì)解答
    #include <iostream>
    using namespace std;
    int main()
    {
         char c;
         int el=0,sp=0,nu=0,other=0; 
         
         while(cin.get(c))
         {
                 if(c=='\n')
                            break;
                 if((c>='A' && c<='Z')||(c>='a' && c<='z'))
                      el++;
                 else if(c>='0'&&c<='9')
                     nu++;
                 else if(c==' ')
                     sp++;
                 else 
                      other++;
         }
         cout<<"英文字母個數(shù)="<<el<<endl<<"數(shù) 字 個 數(shù) ="<<nu<<endl<<"空 格 字 數(shù) ="<<sp<<endl<<"其他字符個數(shù)="<<other<<endl;
         system("pause");
         return 0;
    }

    望采納!

    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版