標題:
if...else if...else 判斷式
[打印本頁]
作者:
陳品肇
時間:
2018-8-2 00:23
標題:
if...else if...else 判斷式
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x, y;
cout<<"輸入x: ";
cin>>x;
cout<<"輸入y: ";
cin>>y;
if(x==y)
{
cout<<"x=y"<<endl;
}else if(x>y)
{
cout<<"x>y"<<endl;
}else
{
cout<<"x<y"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
傅臣嘉
時間:
2018-8-2 10:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
if(a>b)
{
cout<<"a大於b"<<endl;
}
else if(a<b)
{
cout<<"a小於b"<<endl;
}
else
{
cout<<"a等於b" <<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
邱泰澄
時間:
2018-8-2 10:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x, y;
cout<<"輸入x: ";
cin>>x;
cout<<"輸入y: ";
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;
}
複製代碼
作者:
蔡睿紘
時間:
2018-8-2 10:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int ss;
cout<<"你的成績?"<<"A:";
cin>>ss;
cout<<ss;
if(ss>=95)
{
cout<<"高材生!! ";
}
else if(ss>=60)
{
cout<<"及格 ";}
else
{
cout<< "不及格 " ;
}
system("pause");
return 0;
}
複製代碼
作者:
湯郡一
時間:
2018-8-2 10:35
本帖最後由 湯郡一 於 2018-8-2 10:37 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a"<<endl;
cin>>a;
cout<<"請輸入b"<<endl;
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
if (a>b)
{
cout<<"a大於b";
}
else if (a<b)
{
cout<<"a小於b";
}
else
{
cout<<"a等於b";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
曾彥鈞
時間:
2018-8-2 10:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
if(a>b)
{
cout<<"a>b" <<endl ;
}
else if(a<b)
{
cout<<"a<b"<<endl;
}
else
{
cout<<"a=b"<<endl;
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃資尹
時間:
2018-8-2 10:42
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"輸入a:";
cin>>a;
cout<<"輸入b:";
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
if(a>b)
{
cout<<"a>B"<<endl;
}
else if(a<b)
{
cout<<"a<B"<<endl;
}
else
{
cout<<"a=B"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
曾宥承
時間:
2018-8-2 10:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a: ";
cin>>a;
cout<<"請輸入b: ";
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
if(a>b)
{
cout<<"a大於b"<<endl;
}
else if(a<b)
{
cout<<"a小於b"<<endl;
}
else
{
cout<<"a等於b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳潔歆
時間:
2018-8-2 10:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
if(a>b)
{
cout<<"a大於b"<<endl;
}
else if(a<b)
{
cout<<"a小於b"<<endl;
}
else
{
cout<<"a等於b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
田宇任
時間:
2018-8-2 10:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int X,Y;
cout<<"輸入X:";
cin>>X;
cout<<"輸入Y:";
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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2