返回列表 發帖
[code]#include<iostream>
#include<cstdlib>
using namespace std;
int main()  //int ---> integer 整數
{
    int x=12,y=5;  //宣告變數
    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;
}

TOP

[code]#include<iostream>
#include<cstdlib>
using namespace std;
int main()  //int ---> integer 整數
{
    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;
}

TOP

返回列表