返回列表 發帖

五則運算

本帖最後由 tonyh 於 2017-1-24 10:07 編輯

+  加
-   減     
*  乘
/   除
% 取餘數
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=12,y=7;  
  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=95,y=19;   
  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=23,y=7;  
  7.       
  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=91011,y=5678;
  7.    
  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.    
  15.     system("pause");
  16.     return 0;
  17. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     // 五則運算
  7.     int x=23,y=7;
  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.    
  15.     system("pause");
  16.     return 0;
  17. }
複製代碼

TOP

[code#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
   int w=8,s=9;
   cout<<"w的質為"<<w<<",s的質為" <<s<<"時..."<<endl;
   cout<<"w+s="<<w+s<<endl;
   cout<<"w-s="<<w-s<<endl;
   cout<<"w*s="<<w*s<<endl;
   cout<<"w/s="<<w/s<<endl;
   cout<<"w%s="<<w%s<<endl;
   system("pause");
   return 0;
}][/code]

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int w=8,s=9;
  7.    cout<<"w的質為"<<w<<",s的質為" <<s<<"時..."<<endl;
  8.    cout<<"w+s="<<w+s<<endl;
  9.    cout<<"w-s="<<w-s<<endl;
  10.    cout<<"w*s="<<w*s<<endl;
  11.    cout<<"w/s="<<w/s<<endl;
  12.    cout<<"w%s="<<w%s<<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=987,y=654;
  7.    
  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.    
  15.     system("pause");
  16.     return 0;
  17. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int X=515664,Y=645;
  7.    
  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.    
  15.    system("pause");
  16.    return 0;
  17. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=23,y=7;  
  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=26,y=11;
  7.    
  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.          
  15.     system("pause");
  16.     return 0;      
  17. }      
複製代碼

TOP

  1. #include<iostream> //
  2. #include<cstdlib> //
  3. using namespace std; //
  4. int main()//
  5. {
  6.     int x=1414,y=214;
  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

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;  
  4. int main()
  5. {
  6. int  x=1, y=1;
  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.    
  7.    
  8.     int x=23,y=7;
  9.    
  10.      cout<<"當x的值為"<<x<<",y的值為"<<y<<"時..."<<endl;
  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. }     
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=23,y=7;
  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;
  7.     cout<<"請輸入一整數:";
  8.     cin>>a;
  9.     cout<<"你輸入的數字是"<<a<<endl;
  10.    
  11.    
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     cout<<"請輸入一整數:";
  7.     int a;
  8.     cin>>a;
  9.     cout<<"你輸入的數字是"<<a<<endl;
  10.    
  11.     system("pause");
  12.     return 0;
  13. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int a;
  7.    cout<<"請輸入一個整數:";  
  8.    cin>>a;
  9.    cout<<"您輸入的數字是"<<a<<endl;
  10.    system("pause");
  11.    return 0;
  12. }
複製代碼

TOP

返回列表