標題:
if...else if...else 判斷式
[打印本頁]
作者:
tonyh
時間:
2016-8-4 13:59
標題:
if...else if...else 判斷式
本帖最後由 tonyh 於 2016-8-4 14:57 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a, b;
cout<<"請輸入a: ";
cin>>a;
cout<<"請輸入b: ";
cin>>b;
if(a>b)
{
cout<<"a>b"<<endl;
}else if(a<b)
{
cout<<"a<b"<<endl;
}else
{
cout<<"a=b"<<endl;
}
system("pause");
return 0;
}
/*
> 大於
< 小於
== 等於
>= 大於或等於
<= 小於或等於
!= 不等於
*/
複製代碼
作者:
翁梓庭
時間:
2016-8-4 14:07
#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;
}
複製代碼
作者:
黃謙儒
時間:
2016-8-4 14:10
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
if(a>b)
{
cout<<"a大於b"<<endl;
}
else if(a<b)
{
cout<<"a小於b"<<endl;
}
else
{
cout<<"a等於b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
許紘誌
時間:
2016-8-4 14:11
#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;
}
複製代碼
作者:
謝東宏
時間:
2016-8-4 14:12
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a, b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
if(a>b)
{
cout<<"a>b"<<endl;
}
else if(a<b)
{
cout<<"a<b"<<endl;
}
else
{
cout<<"a=b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
許博堯
時間:
2016-8-4 14:12
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout << "請輸入 a:";
cin >> a;
cout << "請輸入 b:";
cin >> b;
cout << "a=" <<a<< endl;
cout << "b=" <<b<< endl;
if(a < b)
{
cout << "a 大於 b" << endl;
}
if(a < b)
{
cout << "a 小於 b" << endl;
}
if(a < b)
{
cout << "a 等於 b" << endl;
}
system("pause");
return 0;
}
複製代碼
作者:
曾堂桂
時間:
2016-8-4 14:13
#clude<iostream>
#clude<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<a<<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
}
複製代碼
作者:
羅巧雯
時間:
2016-8-4 14:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout<<"請輸入a";
cin>>a;
cout<<"請輸入b";
cin>>b;
if(a>b)
{
cout<<"a>b"<<endl;
}else if(a<b)
{
cout<<"a<b"<<endl;
}else
{
cout<<"a=b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
鍾瀚磊
時間:
2016-8-4 14:14
#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;
}
複製代碼
作者:
宋秉軒
時間:
2016-8-4 14:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int 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;
}
複製代碼
作者:
林政昕
時間:
2016-8-4 14:15
#include<iostream>
#include<iostream>
using namespace std;
int main()
{
int a;
int 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;
}
複製代碼
作者:
洪巧芸
時間:
2016-8-4 14:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a, b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
if(a>b)
{
cout<<"a>b"<<endl;
}else if(a<b){
cout<<"a<b"<<endl;
}else{
cout<<"a=b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
翁苡熏
時間:
2016-8-4 14:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int 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;
}
複製代碼
作者:
楊采真
時間:
2016-8-4 14:17
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;
}
複製代碼
作者:
沈子耘
時間:
2016-8-4 14:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int 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;
}
複製代碼
作者:
吳晉榕
時間:
2016-8-4 14:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
if(a<b)
{
cout<<"a大於b"<<enle;
}
else ug (a<b)
{
cout<<"a小於b"<<endl;
}
else
{
cout<<"a等於b"<<endl;
}
system("pause");
restem 0;
}
複製代碼
作者:
許娟慈
時間:
2016-8-4 14:31
#include<iostream>
#include<cstblid>
using namespace std;
int main()
{
int a;
int 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;
}
複製代碼
回復
1#
tonyh
作者:
張紘維
時間:
2016-8-4 14:35
#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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2