返回列表 發帖

五則運算

本帖最後由 tonyh 於 2012-3-14 11:12 編輯

加 +
減 -
乘 *
除 /
取餘數 %
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int x=100,y=15;
  6.     cout<<"x的值為: "<<x<<endl;
  7.     cout<<"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. using namespace std;
  3. int main()                                                                                    
  4. {
  5.    
  6.      int x=20;
  7.      int y=10;   
  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. using namespace std;
  3. int main()
  4. {
  5.      int x=20'                 
  6.      int y=10'
  7.      cout<<""x+y<<endl<<               
  8.      cout<<""x+y<<endl<<                 
  9.      cout<<""x+y<<endl<<                 
  10.      cout<<""x+y<<endl<<
  11.      cout<<""x+y<<endl<<
  12.      system("pause");                     
  13.      return0;                                    
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.       int x=100,y=15;
  6.     cout<<"x的值為: "<<x<<endl;
  7.     cout<<"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. using namespace std;
  3. int main()
  4. {
  5.     int x=100,y=15
  6.     cout<<"x的位值"<<x<<endl;
  7.     cout<<"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

返回列表