Board logo

標題: 五則運算(二) [打印本頁]

作者: 陳品肇    時間: 2018-10-11 21:11     標題: 五則運算(二)

使用 cin 讓使用者能自行指定 x 與 y 的值.
[attach]5000[/attach]
作者: 趙一鳴    時間: 2018-10-13 13:52

本帖最後由 趙一鳴 於 2018-10-13 14:30 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x,y;
  7.     cout<<"請輸入整數x:";
  8.     cin>>x;
  9.     cout<<"請輸入整數y:";
  10.     cin>>y;
  11.     cout<<x<<"+"<<y<<"="<<x+y<<endl;
  12.     cout<<x<<"-"<<y<<"="<<x-y<<endl;
  13.     cout<<x<<"*"<<y<<"="<<x*y<<endl;
  14.     cout<<x<<"/"<<y<<"="<<x/y<<endl;
  15.     cout<<x<<"%"<<y<<"="<<x%y<<endl;
  16.     system("pause");
  17.     return 0;   
  18. }
複製代碼

作者: 洪寬瀧    時間: 2018-10-13 13:57

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.     int x,y;
  8.     cout<<"請輸入x的質:";
  9.     cin>>x;
  10.     cout<<"請輸入y的質:";
  11.      cin>>y;
  12.     cout<<"x+y="<<x+y<<endl;
  13.     cout<<"x-y="<<x-y<<endl;
  14.     cout<<"x*y="<<x*y<<endl;
  15.     cout<<"x/y="<<x/y<<endl;
  16.     cout<<"x%y="<<x%y<<endl;
  17.      system("pause");
  18.      return 0;
  19. }
複製代碼

作者: 曲書辰    時間: 2018-10-13 14:00

本帖最後由 曲書辰 於 2018-10-13 14:01 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int X,Y;
  7.     cout<<"請輸入X的值:";
  8.     cin>>X;
  9.     cout<<"請輸入Y的值:";
  10.     cin>>Y ;
  11.     cout<<X<<" + "<<Y<<" = "<<X+Y<<endl;
  12.     cout<<X<<" - "<<Y<<" = "<<X+Y<<endl;
  13.     cout<<X<<" * "<<Y<<" = "<<X+Y<<endl;
  14.     cout<<X<<" / "<<Y<<" = "<<X+Y<<endl;
  15.     cout<<X<<" % "<<Y<<" = "<<X+Y<<endl;
  16.     system("pause");
  17.     return 0;   
  18.    
  19. }
複製代碼

作者: 章幼莛    時間: 2018-10-13 14:02

本帖最後由 章幼莛 於 2018-10-13 14:29 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float x,y;
  7.     cout<<"請輸入整數x:";
  8.     cin>>x;
  9.     cout<<"請輸入整數y:";
  10.     cin>>y;
  11.     cout<<"當x為:"<<x<<endl;
  12.     cout<<"當y為:"<<y<<endl;
  13.     cout<<x<<"+"<<y<<"="<<x+y<<endl;
  14.     cout<<x<<"-"<<y<<"="<<x-y<<endl;
  15.     cout<<x<<"*"<<y<<"="<<x*y<<endl;
  16.     cout<<x<<"/"<<y<<"="<<x/y<<endl;
  17.     system("pause");
  18.     return 0;
  19. }
複製代碼

作者: 吳孟修    時間: 2018-10-13 14:08

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   int x,y;
  7.   cout<<"請輸入一個整數:";
  8.   cin>>x;
  9.   cout<<"請再輸入一個整數:";
  10.   cin>>y;
  11.   cout<<x<<"+"<<y<<"="<<x+y<<endl;
  12.   cout<<x<<"-"<<y<<"="<<x-y<<endl;
  13.   cout<<x<<"*"<<y<<"="<<x*y<<endl;
  14.   cout<<x<<"/"<<y<<"="<<x/y<<endl;
  15.   cout<<x<<"%"<<y<<"="<<x%y<<endl;
  16.   system("pause");   
  17.   return 0;
  18. }
複製代碼

作者: 葉映琁    時間: 2018-10-13 14:08

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int X=10,Y=3;
  7.     cout<<"請輸入X值:";
  8.     cin>>X;
  9.     cout<<"請輸入Y值:";
  10.     cin>>Y;
  11.     cout<<"X+Y="<<X+Y<<endl;
  12.     cout<<"x-Y="<<X-Y<<endl;
  13.     cout<<"X*Y="<<X*Y<<endl;
  14.     cout<<"X/Y="<<X/Y<<endl;
  15.     cout<<"X%Y="<<X%Y<<endl;
  16.     system("pause");
  17.     return 0;
  18.                            
  19. }
複製代碼

作者: 周孫印    時間: 2018-10-13 14:09

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x,y;
  7.     cout<<"請輸入x的值:";
  8.       cin>>x;
  9.     cout<<"請輸入y的值:";
  10.       cin>>y;
  11.        cout<<x<<"*"<<y<<x+y<<endl;
  12.     cout<<"x-y="<<x-y<<endl;
  13.     cout<<"x*y="<<x*y<<endl;
  14.     cout<<"x/y="<<x/y<<endl;
  15.     cout<<"x%y="<<x%y<<endl;
  16.      system("pause");
  17.      return 0;
  18. }  
複製代碼

作者: 吳孟書    時間: 2018-10-13 14:09

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x,y;
  7.     cout<<"請輸入x的值:";
  8.     cin>>x;
  9.     cout<<"請輸入y的值:";
  10.     cin>>y;
  11.     cout<<x<<"+"<<y<<"="<<x+y<<endl;
  12.     cout<<x<<"-"<<y<<"="<<x-y<<endl;
  13.     cout<<x<<"*"<<y<<"="<<x*y<<endl;
  14.     cout<<x<<"/"<<y<<"="<<x/y<<endl;
  15.     cout<<x<<"%"<<y<<"="<<x%y<<endl;
  16.     system("pause");
  17.     return 0;
  18. }   
複製代碼

作者: 葉千郁    時間: 2018-10-13 14:11

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=10,y=3;
  7.     cout<<"當x的值:";
  8.     cin>>x;
  9.     cout<<"當y的值:";
  10.     cin>>y;
  11.     cout<<"x+y="<<x+y<<endl;
  12.     cout<<"x-y="<<x-y<<endl;
  13.     cout<<"x*y="<<x*y<<endl;
  14.     cout<<"x/y="<<x/y<<endl;
  15.     cout<<"x%y="<<x%y<<endl;
  16.     system("pause");
  17.     return 0;
  18. }
複製代碼

作者: 王瑞喻    時間: 2018-10-13 14:11

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x,y;
  7.    
  8.     cout<<"請輸入一整數x:";
  9.     cin>>x;
  10.     cout<<"請輸入一整數y:";
  11.     cin>>y;
  12.    
  13.     cout<<x<<"+"<<y<<"="<<x+y<<endl;
  14.     cout<<x<<"-"<<y<<"="<<x-y<<endl;
  15.     cout<<x<<"*"<<y<<"="<<x*y<<endl;
  16.     cout<<x<<"/"<<y<<"="<<x/y<<endl;
  17.     cout<<x<<"%"<<y<<"="<<x%y<<endl;
  18.    
  19.     system("pause");
  20.     return 0;
  21.    
  22.    
  23.     }
複製代碼





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