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