返回列表 發帖

五則運算(一)

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
    int x=10, 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;
    cout<<"x%y="<<x%y<<endl;
    system("pause");
    return 0;   
}
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  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 x=23 , y=87;
  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. }




  17.      
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6. int w=10, x=3;
  7. cout<<"w="<<w<<", x="<<x<<endl;
  8. cout<<"w+x="<<w+x<<endl;
  9. cout<<"w-x="<<w-x<<endl;
  10. cout<<"w*x="<<w*x<<endl;
  11. cout<<"w/x="<<w/x<<endl;
  12. cout<<"w%x"<<w%x<<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=13,y=10;
  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<<"a"<<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=13,y=10;
  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>   //input&output
  2. #include<cstdlib>  //standardliburary
  3. using namespace std;
  4. int main()  //主函式
  5. {
  6.     int x=3, y=2;
  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.     system("pause");
  13.     return 0;
  14. }      
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=8;
  7.     int y=7;
  8.     cout<<"當X="<<x<<",y="<<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.     cout<<"x%y="<<x%y<<endl;
  14.     system("pause");
  15.     return 0;
  16.    
  17. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.     int x=5,y=6;
  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.    
  17. }
複製代碼

TOP

返回列表