- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- cout<<"兩數的五則運算"<<endl;
- int x;
- int y;
- cout<<"請輸入x的值"<<endl;
- cin>>x;
- cout<<"請輸入y的值"<<endl;
- cin>>y;
- if(x!=0 && y!=0)
- {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;
- }
- else
- {cout<<"x與y值不可為0 請重新輸入!"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |