返回列表 發帖

【2-2】五則運算

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

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()  //int ---> integer 整數
  5. {
  6.     int x=12,y=5;  //宣告變數
  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. }
複製代碼

[code]#include<iostream>
#include<cstdlib>
using namespace std;
int main()  //int ---> integer 整數
{
    int x,y;
    cout<<"請輸入x";
    cin>>x;
    cout<<"請輸入y:";
    cin>>y;
    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,y=8;
  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.     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.    
  18.     system("pause");
  19.     return 0;
  20. }   
  21.    






  22. #include<iostream>
  23. #include<cstdlib>
  24. using namespace std;
  25. int main()
  26. {
  27.     //五則運算
  28.     //int x;
  29.     //int y;
  30.     int x=23,y=7;
  31.    
  32.     cout<<"當x的值為"<<x<<",y的值為"<<y<<"時..."<<endl;
  33.     cout<<"x+y="<<x+y<<endl;
  34.     cout<<"x-y="<<x-y<<endl;
  35.     cout<<"x*y="<<x*y<<endl;
  36.     cout<<"x/y="<<x/y<<endl;
  37.     cout<<"x%y="<<x%y<<endl;
  38.    
  39.     system("pause");
  40.     return 0;
  41. }   
  42.    
複製代碼

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=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=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. }
  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
複製代碼

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.    
  18.     system("pause");
  19.     return 0;
  20. }   
  21.    
複製代碼

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. cout<<"當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()  //int ---> integer 整數
  5. {
  6.     int x=12,y=5;  //宣告變數
  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()  //int ---> integer 整數
  5. {
  6.     int x=12,y=5;  //宣告變數
  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

[code]#include<iostream>
#include<cstdlib>
using namespace std;
int main()  //int ---> integer 整數
{
    int x=12,y=5;  //宣告變數
    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>using namespace std;
  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

#include<iostream>
#include<cstdlib>
using namespace std;
int main()  //int ---> integer 整數
{
    int x=12,y=5;  //宣告變數
    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()//integer
  5. {
  6. //五則運算
  7. //int x;
  8. //int y;
  9. int x=23,y=7;    //宣告兩個整數變數x.y,並指定他們的值

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

  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

#include<iostream>
#include<cstdlib>
using namespace std;
int main()  //int ---> integer 整數
{
    int x=23,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

返回列表