本帖最後由 tonyh 於 2012-3-14 11:17 編輯
讓使用者自行輸入x與y的值- #include<iostream>
- using namespace std;
- int main()
- {
- int x, y;
- cout<<"請輸入x的值: ";
- cin>>x;
- cout<<"請輸入y的值: ";
- cin>>y;
- cout<<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;
- cout<<x<<"%"<<y<<"="<<x%y<<endl;
- system("pause");
- return 0;
- }
複製代碼 |