返回列表 發帖

五則運算

+  加
-   減     
*  乘
/   除
% 取餘數
  1. #include<iostream> // 引入標頭檔 Input & Output  用來做輸入和輸出使用
  2. #include<cstdlib> // 引入標頭檔函式庫
  3. using namespace std;//命名空間
  4. int main()
  5. {   

  6.     int number1 = 23;
  7.     int number2 = 7;
  8.    
  9.     cout << number1+number2 << endl;
  10.     cout << number1-number2 << endl;
  11.     cout << number1*number2 << endl;
  12.     cout << number1/number2 << endl;
  13.     cout << number1%number2 << endl; //取餘數
  14.    
  15.     system("pause"); //按任意鍵結束程式 +
  16.    
  17. }
複製代碼

本帖最後由 林孟霆 於 2017-8-1 15:54 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int number1=30;
  7.     int number2=5;
  8.     cout<<number1+number2<<endl;
  9.     cout<<number1-number2<<endl;
  10.     cout<<number1*number2<<endl;
  11.     cout<<number1/number2<<endl;
  12.     cout<<number1%number2<<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 number1 = 23;
  7.     int number2 = 7;
  8.     cout<<number1+number2<<endl;
  9.     cout<<number1-number2<<endl;
  10.     cout<<number1*number2<<endl;
  11.     cout<<number1/number2<<endl;
  12.     cout<<number1%number2<<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 number1=32;
  7.     int number2=14;
  8.     cout<<"number1+number2="<<number1+number2<<endl;
  9.     cout<<"number1-number2="<<number1-number2<<endl;
  10.     cout<<"number1*number2="<<number1*number2<<endl;
  11.     cout<<"number1/number2="<<number1/number2<<endl;
  12.     cout<<"number1%number2="<<number1%number2<<endl;
  13.    
  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.    
  7.     int number1=3;
  8.     int number2=7;
  9.    
  10.     cout<<number1+number2<<endl;
  11.     cout<<number1-number2<<endl;
  12.      cout<<number1*number2<<endl;
  13.      cout<<number1/number2<<endl;
  14.       cout<<number1%number2<<endl;
  15.       
  16.     system("pause");
  17. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int poopoo =209;
  7.     int rgb =321;
  8.     cout<<poopoo+rgb<<endl;
  9.     cout<<poopoo-rgb<<endl;
  10.     cout<<poopoo*rgb<<endl;
  11.     cout<<poopoo/rgb<<endl;
  12.     cout<<poopoo%rgb<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

#include<iostream>  
#include<cstdlib>  
using namespace std;
int main()
{
   
    int number1 = 23;
    int number2 = 7;
   
    cout << number1+number2 << endl;
    cout << number1-number2 << endl;
    cout << number1*number2 << endl;
    cout << number1/number2 << endl;
    cout << number1%number2 << endl; //取餘數
   
    system("pause");
    return 0;

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=2012,y=211;
  7.     cout<<x+y<<"\r\n";
  8.     cout<<x-y<<"\r\n";
  9.     cout<<x*y<<"\r\n";
  10.     cout<<x/y<<"\r\n";
  11.     cout<<x%y<<"\r\n";
  12.     system("pause");
  13.     return 0;
  14. }   
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6. cout<<"555555"<<endl;
  7. int number = 10;
  8. cin>>number;
  9. cout<<number<<endl;
  10. cout<<"你輸入的文字是:"<<number<<endl;


  11. int x=23,y=7;
  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.          
  20.          
  21. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      int x=23;
  7.      int y=7;
  8.      cout<<x+y<<endl;
  9.      cout<<x-y<<endl;
  10.      cout<<x*y<<endl;
  11.      cout<<x/y<<endl;
  12.      cout<<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.   
  7.    int number1=23;  
  8.    int number2=7;
  9. cout<<"number1+number2="<<number1+number2<<endl;
  10.   cout<<"number1-number2="<<number1-number2<<endl;
  11.   cout<<"number1*number2="<<number1*number2<<endl;
  12.   cout<<"number1/number2="<<number1/number2<<endl;
  13.   cout<<"number1%number2="<<number1%number2<<endl;
  14.   
  15.   system("pause");
  16.   return 0;   
  17. }
複製代碼

TOP

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6. int number=0;
  7. string str="";
  8. cout<<number<<endl;
  9. cin>>number;
  10. cin>>str;
  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. cout<<str<<endl;
  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= 23;int y = 7;
  8.    
  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.    
  15.    
  16.    
  17.    
  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 number1=23
  7.    int number2=7
  8.    
  9.    cout<<number1+number2<<endl;
  10.    cout<<number1-number2<<endl;
  11.    cout<<number1*number2<<endl;
  12.    cout<<number1/number2<<endl;
  13.    cout<<number1%number2<<endl;
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6. int number1=23;
  7. int number2=7;

  8.    cout<<number1+number2<<endl;
  9.     cout<<number1-number2<<endl;
  10.     cout<<number1*number2<<endl;
  11.     cout<<number1/number2<<endl;
  12.     cout<<number1%number2<<endl;
  13.    
  14.     system("pause");
  15.     return 0;
  16. }
複製代碼

TOP

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int  number1=58;int number2=93;
   cout<<number1+number2<<endl;
   cout<<number1-number2<<endl;
   cout<<number1*number2<<endl;
   cout<<number1/number2<<endl;
   cout<<number1%number2<<endl;
   system("pause");
   return 0;  

}

TOP

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
  int x=23;
  int 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;
   
  string str="";
  float flo=0;
//  cin>>number;
// cout<<number<<endl;

  cout<<str<<endl;
  system("pause");
  return 0;   
}

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      int number1=54;
  7.      int number2=8;
  8.      cout<<"number1+number2="<<number1+number2<<endl;
  9.      cout<<"number1-number2="<<number1-number2<<endl;
  10.      cout<<"number1*number2="<<number1*number2<<endl;
  11.      cout<<"number1/number2="<<number1/number2<<endl;
  12.      cout<<"number1%number2="<<number1%number2<<endl;
  13.      
  14.      
  15.      
  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 number1=23;
  7.      int number2=7;
  8.      cout<<number1+number2<<endl;
  9.      cout<<number1-number2<<endl;
  10.      cout<<number1*number2<<endl;
  11.      cout<<number1/number2<<endl;
  12.      cout<<number1%number2<<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=23,y=7;
  7.     cout<<"x+y="<<x+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.    
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

返回列表