返回列表 發帖

五則運算

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


  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=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> //input&output stream
  2. #include<cstdlib>//c standard library
  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.     system("pause");
  14.     return 0;   
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>

  3. using namespace std;
  4. int main()
  5. {
  6.     int a,b;
  7.     cout<<"this program cauculates many weird stuff.\npls input the value of a:";
  8.     cin>>a;
  9.     cout<<"pls input the value of b:";
  10.     cin>>b;
  11.     cout<<"\nthe value of a+b is:\t"<<a+b<<"\nthe value of a-b is :\t"<<a-b<<"\nthe value of a*b is:\t"<<a*b<<"\nthe value of a/b is :\t"<<a/b<<"\nthe value of a%b is :\t"<<a%b<<"\n";
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #incude<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. }
複製代碼
回復 2# 李東諺

TOP

回復 1# 陳育霖
  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

本帖最後由 孟涵 於 2023-5-30 20:00 編輯
  1. #include<iostream>
  2. #include<cstdlid>
  3. using namespace std;
  4. int main()
  5. { int x=10,y=3;
  6. cout<<"當x等於"<<x<<",y等於"<<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. }
  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<uostream>
  2. #incude<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# 陳育霖

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

返回列表