返回列表 發帖

五則運算 (一)

本帖最後由 鄭繼威 於 2022-11-25 19:24 編輯

+    加
-     減
*    乘
/     除(取商數)
%   取餘數


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

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=10, y=3;
  7.     cout<<"when x equals "<<x<<", and y equals "<<y<<":"<<endl;
  8.     cout<<"x/y="<<x/y<<endl;
  9.     cout<<"x*y="<<x*y<<endl;
  10.     cout<<"x+y="<<x+y<<endl;
  11.     cout<<"x-y="<<x-y<<endl;
  12.     system ("pause");
  13.     return 0;
  14. }
複製代碼
Attention Seeker </3

TOP

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

TOP

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

TOP

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

TOP

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

TOP

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int x=69, y=96;
  6.     cout<<"when x equals "<<x<<", and y equals "<<y<<endl;
  7.     cout<<"x+y"<<x+y<<endl;
  8.     cout<<"x-y="<<x-y<<endl;
  9.     cout<<"x*y="<<x*y<<endl;
  10.     cout<<"x/y="<<x/y<<endl;
  11.     cout<<"x%y="<<x%y<<endl;
  12.     system("pause");
  13.     return 0;
  14. }  
複製代碼

TOP

本帖最後由 陳寶綸 於 2022-11-25 20:16 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=10, y=3;
  7.      
  8.     cout<<"當x等於"<<x<<", y等於"<<y<<"時..."<<endl;
  9.     cout<<"x+y=13"<<x+y<<endl;
  10.     cout<<"x-y=7"<<x-y<<endl;
  11.     cout<<"x*y=30"<<x*y<<endl;
  12.     cout<<"x/y=3"<<x/y<<endl;
  13.     cout<<"x%y=1"<<x%y<<endl;
  14.     system("pause");
  15.     return 0;   
  16. }
複製代碼

TOP

8

TOP

  1. #include<iostream>   
  2. #include<cstdlib>   
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=10,y=3
  7.     cout<<"當x等於"<<x<<",y等於"<<y<<"時..."<<endl;
  8.     cout<<"x+y"<<x+y<<endl;
  9.     cout<<"x-y="<<x-y<<endl;
  10.     cout<<"x*y="<<x*y<<endl;
  11.     cout<<"x/y="<<x/y<<endl;
  12.     cout<<"x%y"<<x%y<<endl;

  13. system("pause");  
  14.     return 0;
複製代碼

TOP

  1. #include<iostream>

  2. using namespace std;

  3. int main()
  4. {
  5.     int x=10, y=3;
  6.    
  7.     cout<<"當x等於"<<x<<",y等於"<<y<<"時"<<endl;
  8.    
  9.     cout<<"x+y="<<x+y<<endl;
  10.     cout<<"x-y="<<x-y<<endl;
  11.     cout<<"x*y="<<x*y<<endl;
  12.     cout<<"x/y="<<x/y<<endl;
  13.     cout<<"x%y="<<x%y<<endl;
  14.    
  15.     system("pause");
  16.     return 0;
  17. }
複製代碼

TOP

本帖最後由 鄭繼威 於 2022-11-25 19:55 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=10, y=3;
  7.     cout<<"當x等於"<<x<<", y等於"<<y<<"時..."<<endl;
  8.     cout<<"x+y="<<x+y<<endl;
  9.     cout<<"x-y="<<x-y<<endl;
  10.     cout<<"x*y="<<x*y<<endl;
  11.     cout<<"x/y="<<x/y<<endl;
  12.     cout<<"x%y="<<x%y<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

  1. #include<iostream>    //引入  <標準函示庫>     標頭檔  c standard  library
  2. #include<cstdlib>     //引入  <基本輸入輸出>   標頭檔    input  &  output  stream
  3. using namespace std;  //指定命名空間為    std
  4. int main()   //主函式
  5. {
  6.     int x=10,y=3;
  7.         cout<<"當x等於"<<x<<", y等於"<<y<<"時..."<<endl;
  8.         cout<<"x+y="<<x+y<<endl;
  9.         cout<<"x-y="<<x-y<<endl;
  10.         cout<<"x*y="<<x*y<<endl;
  11.         cout<<"x/y="<<x/y<<endl;
  12.     cout<<"x%y="<<x%y<<endl;
  13.        

  14.     system("pause");       // 讓畫面暫停
  15.     return 0;             //回傳到主控台,告知該程式已成功執行
  16. }
複製代碼

TOP

返回列表