返回列表 發帖

四則運算(一)

  1. #include<iostream>  //輸入輸出
  2. #include<cstdlib>   //函式庫
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.    
  8.    cout << "1+1= " << 1+1 << endl;  //字串 要用""包起來     如果要加上其他輸出的內容   <<
  9.    //"字串" 印出一模一樣的字   
  10.    // 1+1   印出運算的值
  11.    cout << "2-1= " << 2-1 << endl;
  12.    cout << "4*6= " << 4*6 << endl;
  13.    cout << "4/2= " << 4/2 << endl;
  14.    cout << "7除以5的餘數是 " << 7%5 << endl; //取餘數
  15.    //    7/5 =1..2(餘數)
  16.    
  17.    system("pause");
  18.    return 0;
  19. }
複製代碼

  1. int  main()
  2. {
  3. cout<<"1+1"<<1+1<<endl;
  4. cout<<"2-1"<<2-1<<endl;
  5. cout<<"4*6"<<4*6<<endl;
  6. cout<<"4/2"<<4/2<<endl;
  7. cout<<"7/5的餘數是"<<7%5<<endl;
  8. system("pause");
  9. return 0;
  10. }
複製代碼

TOP

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()

  5. {
  6. cout<<"2-1="<<2-1<<endl;
  7. cout<<"1+1="<<1+1<<endl;
  8. cout<<"4*6="<<4*6<<endl;
  9. cout<<"4/2="<<4/2<<endl;
  10. cout<<"7%5="<<7%5<<endl;        
  11. system("pause");
  12. return 0;
  13. }
複製代碼

TOP

  1. #include<iostream>   
  2. #include<cstdlib>   
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.    
  8.    cout << "1+1= " << 1+1 << endl;  
  9.    
  10.    cout << "2-1= " << 2-1 << endl;
  11.    cout << "4*6= " << 4*6 << endl;
  12.    cout << "4/2= " << 4/2 << endl;
  13.    cout << "7/5=" << 7%5 << endl;



  14. system("pause");
  15.    return 0;
  16. }
複製代碼

TOP

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

TOP

  1. #include<iostream>   
  2. #include<cstdlib>   
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.    
  8.    cout << "1+1= " << 1+1 << endl;  
  9.    
  10.    cout << "2-1= " << 2-1 << endl;
  11.    cout << "4*6= " << 4*6 << endl;
  12.    cout << "4/2= " << 4/2 << endl;
  13.    cout << "7/5 " << 7%5 << endl;



  14. system("pause");
  15.    return 0;
  16. }
複製代碼

TOP

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

TOP

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

TOP

返回列表