標題:
五則運算 (二)
[打印本頁]
作者:
tonyh
時間:
2013-1-22 10:59
標題:
五則運算 (二)
讓使用者自己指定x與y的值.
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
羅家恩
時間:
2013-1-22 11:00
#include <iostream>
#include <cstdlib>
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;
}
複製代碼
作者:
吳東哲
時間:
2013-1-22 11:01
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
張鈞
時間:
2013-1-22 11:02
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
林鎧言
時間:
2013-1-22 11:02
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
許育碩
時間:
2013-1-22 11:02
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
許逸群
時間:
2013-1-22 11:03
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y;
cout<<"請輸入x的值";
cin>>x;
cout<<"請輸入y的值";
cin>>y;
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;
}
複製代碼
作者:
郭凡瑛
時間:
2013-1-22 11:03
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
劉得旗
時間:
2013-1-22 11:03
#include<iostream>
#include<cstdlib>
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;
system("pause");
return 0;
}
複製代碼
作者:
林長逸
時間:
2013-1-22 11:04
#include<iostream>
#include<cstdlib>
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;
複製代碼
作者:
李家宇
時間:
2013-1-22 11:04
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x=23,y=7;
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;
}
作者:
鄧皓銘
時間:
2013-1-22 11:05
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
高允懋
時間:
2013-1-22 11:05
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
蘇昱安
時間:
2013-1-22 11:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y;
cout<<"當X的值為"<<x<< ",y的值為"<<y<<"時..."<<endl;
cout<<"請輸入x的值: ";
cin>>x;
cout<<"請輸入y的值: ";
cin>>y;
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;
}
複製代碼
作者:
高紹恩
時間:
2013-1-22 11:06
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int j,o;
cout<<"請輸入j的值= ";
cin>>j;
cout<<"請輸入o的值=";
cin>>o;
cout<<"當j的值為"<<j<<",o的值為"<<o<<"時..."<<endl;
cout<<"j+o="<<j+o<<endl;
cout<<"j-o="<<j-o<<endl;
cout<<"j*o="<<j*o<<endl;
cout<<"j/o="<<j/o<<endl;
cout<<"j%o="<<j%o<<endl;
system("pause");
return 0;
複製代碼
作者:
劉泳鱔
時間:
2013-1-22 11:06
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
作者:
郭妤真
時間:
2013-1-22 11:08
#include<iostream>
#include<cstdlib>
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;
複製代碼
作者:
翁睿辰
時間:
2013-1-22 11:09
#include<iostream>
#include<cstdlib>
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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2