返回列表 發帖

五則運算 (一)

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


  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=8,y=4;
  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=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=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 gay=1234,Gay=5678;
  7.     cout<<"如果gay代表"<<gay<<",Gay代表"<<Gay<<"時"<<endl;
  8.     cout<<"gay+Gay="<<gay+Gay<<endl;
  9.     cout<<"gay-Gay="<<gay-Gay<<endl;
  10.      cout<<"gay*Gay="<<gay*Gay<<endl;
  11.      cout<<"gay/Gay="<<gay/Gay<<endl;
  12.      cout<<"gay%Gay="<<gay%Gay<<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

本帖最後由 陳宥穎 於 2019-7-26 19:48 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=122,y=111;
  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.    
  16. }
複製代碼

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=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

返回列表