返回列表 發帖

五則運算

本帖最後由 tonyh 於 2017-2-3 14:45 編輯

+  加
-   減     
*  乘
/   除
% 取餘數
  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. }
複製代碼

#include<iostream>     
#include<cstdlib>
using namespace std;
int main()
{
   int x=10,y=7;
   cout<<"當x的值為"<<x<<",y的值為"<<y<<"時..."<<endl;
   cout<<"x+Y="<<x+y<<endl;
   cout<<"x-Y="<<x-y<<endl;
   cout<<"x*Y="<<x*y<<endl;
   cout<<"x/Y="<<x/y<<endl;
   cout<<"x%Y="<<x%y<<endl;
   system("pause");
   return 0;
}

TOP

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     //五則運算
  7.     //int x;
  8.     //int y;
  9.     int x=23;
  10.     int y=7;
  11.     cout<<"當x的值為"<<x<<",y的值為"<<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.     cout<<"x%y="<<x%y<<endl;
  17.    
  18.     system("pause");
  19.     return 0;
  20. }   
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     //五則運算
  7.     //int x;
  8.     //int y;
  9.     int x=23,y=7;
  10.    
  11.     cout<<"當x的值為"<<x<<",y的值為"<<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.      cout<<"x%y="<<x%y<<endl;
  17.      cout<<"呵呵呵呵呵呵呵呵呵呵"<<endl;
  18.      
  19.     system("pause");
  20.     return 0;
  21. }
複製代碼

TOP

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   int x=888,y=666;
  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. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int x=10,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. }
  16.   
複製代碼

TOP

本帖最後由 柯識一 於 2017-2-3 14:31 編輯
  1. #include<iostream>     
  2. #include<cstdlib>      
  3. using namespace std;   
  4. int main()   
  5. {
  6.     int x=123456789,y=987654321;
  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.    
  9.    cout<<"當x的值為"<<x<<",y的值為"<<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.    cout<<"x%y="<<x%y<<endl;
  15.    
  16.    
  17.    system("pause");
  18.    return 0
  19.      
  20. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=99 , y=86;
  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.    //int x;
  8.    //int y;
  9.    int x=23,y=7;
  10.    
  11.    cout<<"當x的值為"<<x<<",y的值為"<<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.    cout<<"x%y="<<x%y<<endl;

  17.    system("pause");
  18.    return 0;
  19. }
複製代碼

TOP

返回列表