Board logo

標題: 2023/10/28 上課重點(家鉌) [打印本頁]

作者: 陳育霖    時間: 2023-10-27 18:26     標題: 2023/10/28 上課重點(家鉌)

本帖最後由 陳育霖 於 2023-10-27 19:13 編輯

遠距教學連結
會議連結 - 1

會議連結 - 2

今日課堂重點:
複習字串處理 (六) - 取得字串長度 1
複習字串處理 (七) - 取得字串長度 2
字串處理 (八) - 將字串轉換為ASCII碼
字串處理 (九) - 將ASCII碼轉換為字串
403 字串與檔案處理 (字串大小寫轉換)
字串處理 (十) - 判斷大小寫
stringstream 字串串流 (一)
stringstream 字串串流 (二)

今日考試:
401 字串與檔案處理 (字串長度與連結)

作者: 林家鉌    時間: 2023-10-28 14:57

林家鉌 2023/10/28 簽到
作者: 林家鉌    時間: 2023-10-28 15:00

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. float b=0;
  4. int a;
  5. int cab(int r)
  6. {
  7.         if(r==0)
  8.         {
  9.                 b++;
  10.         }
  11.         return b;
  12. }
  13. void pr(int r)
  14. {
  15.         if(r==1)
  16.         {
  17.                 cout<<"front";
  18.         }
  19.         else
  20.         {
  21.                 cout<<"back";
  22.         }
  23. }
  24. void ed()
  25. {
  26.         cout<<"\n\nfront: "<<a-b<<"\tback: "<<b<<"\nThe proportion of the front is: "<<(a-b)/a*100<<"%\nthe proportion of the back is: "<<b/a*100<<"%";       
  27. }
  28. int main()
  29. {
  30.         cout<<":";
  31.         cin>>a;
  32.         srand(time(NULL));
  33.         int r=0;
  34.         for(int i=0;i<a;i++)
  35.         {
  36.                 r=rand()%2;
  37.                 pr(r);
  38.                 cab(r);
  39.                 cout<<"\n";
  40.         }
  41.         ed();
  42.         return 0;
  43. }       
複製代碼

作者: 陳育霖    時間: 2023-10-28 15:05

2023/10/28




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