Board logo

標題: 602 字串拆解 [打印本頁]

作者: 李知易    時間: 2024-12-20 22:58     標題: 602 字串拆解

1. 題目說明:
請依下列題意進行作答,使輸出值符合題意要求。

2. 設計說明:
請撰寫一程式,讓使用者輸入一個包含英文大小寫的字串,並依序將字串中的大、小寫字母分離,最後依序輸出字串中的大寫字串、小寫字串及大寫字母的數量。

提示:若使用 Java 語言答題,請以「JP」開頭命名包含 main 靜態方法的 class,評測系統才能正確評分。

3. 輸入輸出:
輸入說明
一個包含英文大小寫的字串

輸出說明
字串中的大寫字串、小寫字串及大寫字母的數量

範例輸入
ComPuTer
範例輸出
CPT
omuer
3


本帖隱藏的內容需要回復才可以瀏覽

作者: 李穎俊    時間: 2024-12-21 14:33

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string  str,s1,s2;
  4. int main(){
  5.     getline(cin,str);
  6.     for(char c:str){
  7.         if(c>='A' && c<='Z')
  8.             s1+=c;
  9.         else
  10.             s2+=c;
  11.     }
  12.     cout<<s1<<endl<<s2<<endl;
  13.     cout<<s1.length();
  14.     return 0;
  15. }
複製代碼

作者: 張淯祺    時間: 2024-12-21 14:34

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string str,s1,s2;
  4. int main()
  5. {
  6.     getline(cin,str);
  7.     for(char c:str)
  8.     {
  9.         if(c>='A'&&c<='Z')
  10.             s1+=c;
  11.         else
  12.             s2+=c;
  13.     }
  14.     cout<<s1<<endl;
  15.     cout<<s2<<endl;
  16.     cout<<s1.length()<<endl;

  17.     return 0;
  18. }
複製代碼

作者: 洪榮辰    時間: 2024-12-21 14:34

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     string str, s1, s2;
  6.     getline(cin, str);
  7.     for(char c : str)
  8.     {
  9.         if(c>='A' && c<='Z')
  10.             s1+=c;
  11.         else
  12.             s2+=c;
  13.     }
  14.     cout<<s1<<endl;
  15.     cout<<s2<<endl;
  16.     cout<<s1.length()<<endl;
  17. }
複製代碼

作者: 蔡岑昕    時間: 2024-12-21 14:35

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string str,s1,s2;
  4. int main()
  5. {
  6.     getline(cin,str);
  7.     for(char c:str)
  8.     {
  9.         if(c>='A' && c<='Z')
  10.             s1+=c;
  11.         else
  12.             s2+=c;
  13.     }
  14.     cout<<s1<<endl;
  15.     cout<<s2<<endl;
  16.     cout<<s1.length()<<endl;
  17.     return 0;
  18. }
複製代碼

作者: 劉秉昕    時間: 2024-12-21 14:35

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string str,s1,s2;
  4. int main()
  5. {
  6.     getline(cin,str);
  7.     for(char c:str)
  8.     {
  9.         if(c>='A' && c<='Z')
  10.             s1+=c;
  11.         else
  12.             s2+=c;
  13.     }
  14.     cout<<s1<<endl;
  15.     cout<<s2<<endl;
  16.     cout<<s1.length()<<endl;
  17.     return 0;
  18. }
複製代碼

作者: 張仲言    時間: 2024-12-27 21:31

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string str,s1,s2;
  4. int main()
  5. {
  6.         getline(cin,str);
  7.         for(char c:str)
  8.         {
  9.                 if(c>='A' and c<='Z')
  10.                         s1+=c;
  11.                 else
  12.                         s2+=c;
  13.         }
  14.         cout<<s1<<'\n'<<s2<<'\n'<<s1.length()<<'\n';
  15.         return 0;
  16. }
複製代碼

作者: 朱奕祈    時間: 2024-12-28 10:52

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string  str,s1,s2;
  4. int main(){
  5.     getline(cin,str);
  6.     for(char c:str){
  7.         if(c>='A' && c<='Z')
  8.             s1+=c;
  9.         else
  10.             s2+=c;
  11.     }
  12.     cout<<s1<<endl<<s2<<endl;
  13.     cout<<s1.length();
  14.     return 0;
  15. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2