讓使用者自行輸入x與y的值- #include<iostream>
- using namespace std;
- int main()
- {
- int x, y;
- cout<<"請輸入x: ";
- cin>>x;
- cout<<"請輸入y: ";
- cin>>y;
- 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;
- }
複製代碼 |