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