標題:
【3-2】if...else if...else 判斷式
[打印本頁]
作者:
王瑞喻
時間:
2020-2-6 16:30
標題:
【3-2】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;
}
複製代碼
作者:
1090121_1
時間:
2020-2-7 10:11
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout <<"請輸入整數a:"<<endl;
cin>>a;
cout <<"請輸入整數b:"<<endl;
cin>>b;
cout <<"--------------------------------"<<endl;
cout <<"a是"<<a<<", b是"<<b<<endl;
if(a>b)
{
cout <<"a>b ["<<a<<">"<<b<<"]"<<endl;
}
if(a==b)
{
cout <<"a=b ["<<a<<"="<<b<<"]"<<endl;
}
if(a<b)
{
cout <<"a<b ["<<a<<"<"<<b<<"]"<<endl;
}
return 0;
}
複製代碼
作者:
許洺淪
時間:
2020-2-7 10:14
#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;
}
複製代碼
作者:
林子宸
時間:
2020-2-7 10: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;
}
複製代碼
作者:
蔡睿澤
時間:
2020-2-7 10:15
#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;
}
複製代碼
作者:
邱冠睿
時間:
2020-2-7 10:15
#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;
}
複製代碼
作者:
郭典丞
時間:
2020-2-7 10:16
#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;
}
複製代碼
作者:
林鼎傑
時間:
2020-2-7 10:17
#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;
}
複製代碼
作者:
陳芷愉
時間:
2020-2-7 10:23
#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;
}
複製代碼
作者:
簡世釗
時間:
2020-2-7 10:25
#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;
}
複製代碼
作者:
俞成章
時間:
2020-2-7 10:25
#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;
}
複製代碼
作者:
張全祐
時間:
2020-2-7 10:26
#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;
}
複製代碼
作者:
陳暐勛
時間:
2020-2-7 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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2