Board logo

標題: 2025/1/17 課堂重點(若恩) [打印本頁]

作者: 郭竑志    時間: 2025-1-17 20:07     標題: 2025/1/17 課堂重點(若恩)

[作業檢查]
310 函式與陣列 (阿姆斯壯數)
[課堂重點]
401 字串與檔案處理 (字串長度與連結)
402 字串與檔案處理 (字串比較)
404 字串與檔案處理 (字母出現次數)
405 字串與檔案處理 (讀取檔案並修改)
406 字串與檔案處理 (判斷字元並修改)
407 字串與檔案處理 (字元刪除及另存新檔)
[今日作業]
403 字串與檔案處理 (字串大小寫轉換)
作者: 何若恩    時間: 2025-1-17 20:34

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(int argc, char** argv) {
  4.     string a, b;
  5.     cin>>a>>b;
  6.     cout<<a.length()<<endl;
  7.     cout<<b.length()<<endl;
  8.     cout<<a+b;
  9.     return 0;
  10. }
複製代碼

作者: 何若恩    時間: 2025-1-17 20:59

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(int argc, char** argv) {
  4.     char a[100], b[100];
  5.     int n, atotal, btotal;
  6.     cin>>a>>b>>n;
  7.     for(int i=0;i<=a[n];i++){
  8.         atotal+=int(a[i]);
  9.     }
  10.     for(int i=0;i<=b[n];i++){
  11.         btotal+=int(b[i]);
  12.     }
  13.     if(atotal=btotal){
  14.         cout<<"atotal=btotal";
  15.     }else if(atotal>btotal){
  16.         cout<<"atotal>btotal";   
  17.     }else if(atotal<btotal){
  18.         cout<<"atotal<btotal";   
  19.     }
  20.    
  21.     return 0;
  22. }
複製代碼

作者: 郭竑志    時間: 2025-1-17 21:43

#include<bits/stdc++.h>
using namespace std;

int main()
{
    ifstream ifs;
    ifs.open("read.txt");
    if(!ifs.is_open())
        cout<<"error"<<endl;
    string s;
    int n;
    while(ifs>>s)
    {
        
    }
}
作者: 何若恩    時間: 2025-2-6 22:22

  1. #include <bits/stdc++.h>
  2. using namespace std;


  3. int main(int argc, char** argv) {
  4.     int a;
  5.     char word[100];
  6.     cin>>word;
  7.     a=strlen(word);
  8.     for(int i=0;i<a;i++){
  9.         if(islower(word[i])){
  10.             cout<<(char)toupper(word[i]);
  11.         }else if(isupper(word[i])){
  12.             cout<<(char)tolower(word[i]);
  13.         }else{
  14.             cout<<word[i];            
  15.         }
  16.     }
  17.     return 0;
  18.     }
複製代碼





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