返回列表 發帖

五則運算 (一)

+    加 (5+3=8)
-     減 (5-3=2)
*    乘 (5*3=15)
/     除 (5/3=1)
%   取餘數 (5%3=2)

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;

  4. int main()
  5. {
  6.     int x=9487,y=8787;
  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 x=20`y=1
    x+y=21
    x-y=19
    x*y=20
    x/y=20
    x%y=0
    system("pause");   
    return 0;
         }

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;

  4. int main()
  5. {
  6.     int x=61610487,y=4113487;
  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

#include<iostream>
#include<cstdlib>
using namespace std;
{
     int x=5,y=3;
     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;
     
      

     system("pause")
     return 0;
}

TOP

#include<iostream>
#include<cstdlib>
using namespace std;
int main ()
{
    int x=20,y=1;
    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 a=8,j=7;
  7.     cout<<"當a等於八,當j等於七時..."<<endl;
  8.     cout<<"a+j="<<a+j<<endl;
  9.     cout<<"a-j="<<a-j<<endl;
  10.     cout<<"a*j="<<a*j<<endl;
  11.     cout<<"a/j="<<a/j<<endl;
  12.     cout<<"a%j="<<a%j<<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=9,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=9,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. }
  16.      
複製代碼

TOP

返回列表