返回列表 發帖

TOP

3.
  1. #include <bits/stdC++.h>//萬用標頭檔
  2. using namespace std;
  3. int main()
  4. {
  5.         srand(time(NULL));
  6.         int question = rand() % 1000 + 1;
  7.     int big, small, guess, count = 0;
  8.     while(count<=10)
  9.     {
  10.             count++;
  11.         std::cin>>guess;
  12.         if(guess > question)  
  13.         {
  14.             big = guess-1;
  15.             std::cout<<"higher"<<std::endl;
  16.             std::cout << std::flush;
  17.         }
  18.                 else if(guess < question)
  19.         {
  20.             small = guess+1;
  21.             std::cout<<"lower"<<std::endl;
  22.             std::cout << std::flush;
  23.         }
  24.         else
  25.         {
  26.             break; //跳離迴圈
  27.         }
  28.         }
  29.     return 0;
  30. }
複製代碼

TOP

4.
  1. #include <bits/stdC++.h>//萬用標頭檔
  2. using namespace std;
  3. int main(){
  4.         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);//加速輸入與輸出
  5.         double a, b;
  6.         std::cin>>a>>b;
  7.         std::cout<<a+b<<"\n";       
  8.         return 0;
  9. }
複製代碼

TOP

本帖最後由 葉桔良 於 2022-11-11 17:43 編輯

2.
  1. #include <bits/stdC++.h>//萬用標頭檔
  2. using namespace std;
  3. int main(){
  4.         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);//加速輸入與輸出
  5.         int x, a, b;
  6.         std::cin>>x;
  7.         if(x <= 2000 && x >= 0)
  8.         {
  9.                 if(x>1000)
  10.                 a=1000;       
  11.                 else
  12.                         a=x/2;
  13.                 b=x-a;
  14.                
  15.                  std::cout<<a<<" "<<b<<"\n";       
  16.     }
  17.         return 0;
  18. }
複製代碼

TOP

1.
  1. #include <bits/stdC++.h>//萬用標頭檔
  2. using namespace std;
  3. int main(){
  4.         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);//加速輸入與輸出
  5.         long long a,b;
  6.         cin>>a>>b;
  7.         cout<<(a+b)<<"\n";
  8.         return 0;
  9. }
複製代碼

TOP

返回列表