返回列表 發帖

五則運算(一)

  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 apple=7,b=6;
  7. cout<<"a=7,b=6"<<endl;
  8. cout<<"結果如下:"<<endl;
  9. cout<<"a+b="<<apple+b<<endl;
  10. cout<<"a-b="<<apple-b<<endl;
  11. cout<<"a*b="<<apple*b<<endl;
  12. cout<<"a/b="<<apple/b<<"餘數"<<apple%b<<endl;
  13. cout<<""<<endl;
  14. system("pause");
  15. return 0;   
  16.    
  17.    
  18. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a,b;
  7.     cout<<"請輸入一個整數";
  8.     cin>>a;
  9.     cout<<"請輸入另一個整數";
  10.     cin>>b;
  11.     cout<<"a是"<<a<<",b是"<<b<<endl;
  12.     cout<<"a+b="<<a+b<<endl;
  13.     cout<<"a-b="<<a-b<<endl;
  14.     cout<<"a*b="<<a*b<<endl;
  15.     cout<<"a/b="<<a/b<<endl;
  16.     cout<<"a%b="<<a%b<<endl;
  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=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,y;
  7.     cout<<"請輸入x=";
  8.     cin>>x;
  9.     cout<<"請輸入y=";
  10.     cin>>y;
  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.    int a;
  7.    int b;
  8.   
  9.    
  10.    cout<<"請輸入一個數並按enter:";
  11.    cin>>a;
  12.    cout<<"請在輸入一個數並按enter:";
  13.    cin>>b;
  14.    cout<<a<<"加"<<b<<"等於"<<a+b<<endl;
  15.    cout<<a<<"減"<<b<<"等於"<<a-b<<endl;
  16.    cout<<a<<"乘"<<b<<"等於"<<a*b<<endl;
  17.    cout<<a<<"除"<<b<<"等於"<<a/b<<"..."<<a%b<<endl;
  18.    
  19.    
  20.    
  21.    
  22.    system("pause");
  23.    return 0;
  24. }
複製代碼

TOP

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

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

返回列表