標題:
if...else if...else 判斷式
[打印本頁]
作者:
tonyh
時間:
2019-7-9 10:10
標題:
if...else if...else 判斷式
#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;
}
複製代碼
作者:
陳昱安
時間:
2019-7-9 10:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"報上你的成績: ";
cin>>score;
if(score>=60)
{
cout<<"恭喜你! 及格了!"<<endl;
}else
{
cout<<"不及格!!!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳龍華
時間:
2019-7-9 10:31
#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;
}
複製代碼
作者:
葉又誠
時間:
2019-7-9 10:34
#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;
}
複製代碼
作者:
張淯祺
時間:
2019-7-9 10:35
#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;
}
複製代碼
作者:
李宇澤
時間:
2019-7-9 10:40
#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;
}
作者:
楊子毅
時間:
2019-7-9 10:42
#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;
}
複製代碼
作者:
吳秉霖
時間:
2019-7-9 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;
}
複製代碼
作者:
林羿丞
時間:
2019-7-9 10:44
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;
}
複製代碼
作者:
張博程
時間:
2019-7-9 10:45
#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 ;
}
複製代碼
作者:
曾博宇
時間:
2019-7-9 10:45
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;
}
複製代碼
作者:
邱士豪
時間:
2019-7-9 10:46
#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;
}
複製代碼
作者:
王柏諺
時間:
2019-7-9 10:46
#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;
}
複製代碼
作者:
王銘鴻
時間:
2019-7-9 10:53
#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;
}
複製代碼
作者:
陳昱安
時間:
2019-7-9 10:59
#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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2