標題:
if...else if...else 敘述
[打印本頁]
作者:
tonyh
時間:
2012-8-7 10:41
標題:
if...else if...else 敘述
#include<iostream>
using namespace std;
int main()
{
int x, y;
cout<<"請輸入x: ";
cin>>x;
cout<<"請輸入y: ";
cin>>y;
cout<<"您剛輸入的x為"<<x<<", y為"<<y<<endl;
if(x>y) //符合什麼條件
{ //做什麼動作
cout<<"x大於y!"<<endl;
}
else if(x<y)
{
cout<<"x小於y!"<<endl;
}
else
{
cout<<"x等於y!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
t2364705
時間:
2012-8-7 10:44
#include<iostream>
using namespace std;
int main()
{
int x, y;
cout<<"請輸入x: ";
cin>>x;
cout<<"請輸入y: ";
cin>>y;
cout<<"您輸入的x為"<<x<<", y為"<<y<<endl;
if(x>y)
{
cout<<"x 大於 y"<<endl;
}else if(x<y)
{
cout<<"x 小於 y"<<endl;
}else
{
cout<<"x 等於 y"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
周旻賢
時間:
2012-8-7 10:45
#include<iostream>
using namespace std;
int main()
{
int x;
int y;
cout<<"請輸入X:"<<endl;
cin>>x;
cout<<"請輸入y:"<<endl;
cin>>y;
cout<<"您輸入的x為:"<<x<<endl;
cout<<"您輸入的y為:"<<y<<endl;
if(x>y)
{
cout<<"x大於y"<<endl;
}
else if(x<y)
{
cout<<"x小於y"<<endl;
}
else
{
cout<<"x等於y"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
蔡昀佑
時間:
2012-8-7 10:45
#include<iostream>
using namespace std;
int main()
{
int x, y;
cout<<"請輸入x: ";
cin>>x;
cout<<"請輸入y: ";
cin>>y;
cout<<"您剛輸入的x為"<<x<<", y為"<<y<<endl;
if(x>y)
{
cout<<x<<"大於"<<y<<"!"<<endl;
}
else if(x<y)
{
cout<<x<<"小於"<<y<<"!"<<endl;
}
else
{
cout<<x<<"等於"<<y<<"!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
許睿森
時間:
2012-8-7 10:46
#include<iostream>
using namespace std;
int main()
{
cout<<"☆☆☆☆☆☆☆☆☆" <<endl;
float x, y;
cout<<"☆請輸入X:";
cin>>x;
cout<<"☆請輸入Y:";
cin>>y;
cout<<"☆你輸入的X為"<<x<<",Y為"<<y<<endl;
if(x>y)
{
cout<<"☆X大於Y"<<endl;
}
else if(x<y)
{
cout<<"☆X小於Y"<<endl;
}
else
{
cout<<"☆X等於Y"<<endl;
}
cout<<"☆☆☆☆☆☆☆☆☆"<<endl ;
system("pause");
return 0;
}
複製代碼
作者:
周煒翔
時間:
2012-8-7 10:49
#include<iostream>
using namespace std;
int main()
{
int x, y;
cout<<"請輸入x:";
cin>>x;
cout<<"請輸入y:";
cin>>y;
cout<<"您剛輸入的x為:"<<x<<"您剛輸入的y為:"<<y<<endl;
if(x>y)
{
cout<<"x大於y"<<endl;
}
else if(x<y)
{
cout<<"x小於y"<<endl;
}
else
{
cout<<"x等於y"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉泳鱔
時間:
2012-8-7 10:52
#include<iostream>
using namespace std;
int main()
{
int x, y;
cout<<"請輸入x:"<<endl;
cin>>x;
cout<<"請輸入y:"<<endl;
cin>>y;
cout<<"您剛輸入x為"<<x<<",y為"<<y<<endl;
if(x>y)
{
cout<<"x大於y"<<endl;
}
else if(x<y)
{
cout<<"x小於y"<<endl;
}
else
{
cout<<"x等於y"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉嘉琳
時間:
2012-8-7 11:01
#include<iostream>
using namespace std;
int main()
{
int x;
int y;
cout<<"請輸入x"<<endl;
cin>>x;
cout<<"請輸入y"<<endl;
cin>>y;
cout<<"您輸入的x為"<<x<<",y為"<<y<<endl;
if(x>y)
{
cout<<"x大於Y"<<endl;
}
else if(x<y)
{
cout<<"x小於Y"<<endl;
}
else
{
cout<<"x等於y"<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2