標題:
if...else if...else 判斷式
[打印本頁]
作者:
王瑞喻
時間:
2021-2-2 10:26
標題:
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;
}
複製代碼
作者:
李天輝
時間:
2021-2-2 10:38
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
float 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"<<endl;
}
else{if(a==b)
{
cout<<"a=b"<<endl;
}
else{
cout<<"a<b"<<endl;
}
}
system("pause");
return 0;
}
複製代碼
作者:
任璿
時間:
2021-2-2 10:46
#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;
}
作者:
李奕廷
時間:
2021-2-2 10:58
#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;
}
複製代碼
回復
1#
王瑞喻
作者:
謝以恩
時間:
2021-2-2 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;
}
複製代碼
作者:
何若晴
時間:
2021-2-2 11:05
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 if(a=b)
{
cout<<"a=b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
蔡宜均
時間:
2021-2-2 11:49
#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;
}
複製代碼
作者:
方黃生
時間:
2021-2-2 13:27
#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;
}
複製代碼
作者:
吳亦勛
時間:
2021-2-2 13:36
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"報上你的成績: ";
cin>>score;
if(score>=60)
{
cout<<"恭喜你! 及格了!"<<endl;
}else
{
cout<<"不及格~ 斬!"w<<endl;
}
system("pause");
return0;
}
複製代碼
作者:
張晏滕
時間:
2021-2-2 14:08
#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;
}
複製代碼
作者:
莊念篪
時間:
2021-2-2 14:09
#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;
}
作者:
王偉樺
時間:
2021-2-2 14:10
#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;
}
複製代碼
作者:
王廷悠
時間:
2021-2-2 14:12
#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;
}
作者:
陳建承
時間:
2021-2-2 14:12
本帖最後由 陳建承 於 2021-2-2 14:31 編輯
#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>)
{
cout<<"a大於b"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張鈊喬
時間:
2021-2-2 14:13
回復
1#
王瑞喻
#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;
}
作者:
怡璇
時間:
2021-2-2 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;
}
複製代碼
作者:
莊鈞宸
時間:
2021-2-2 14:15
#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;
}
複製代碼
作者:
蘇廷祐
時間:
2021-2-2 14:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main0
{
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;
}
複製代碼
作者:
鄧崴仁
時間:
2021-2-2 14:22
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a大於b"<<endl;
cout<<"a小於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;
}
複製代碼
作者:
洪曼崴
時間:
2021-2-2 14:23
#include<iostream>
#include<cstdlib>
using namespace std;
int main() //int ---> integer 整數
{
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等於"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳仕約
時間:
2021-2-2 14: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;
}
複製代碼
作者:
方凱聲
時間:
2021-2-2 14:23
#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;
}
複製代碼
作者:
陳仕約
時間:
2021-2-2 14:24
#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;
}
複製代碼
作者:
鄧崴仁
時間:
2021-2-2 14:26
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a大於b"<<endl;
cout<<"a小於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;
}
作者:
陳仕約
時間:
2021-2-2 14:26
#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://istak.org.tw/seed/)
Powered by Discuz! 7.2