標題:
if...else if...else 判斷式
[打印本頁]
作者:
tonyh
時間:
2015-7-4 09:25
標題:
if...else if...else 判斷式
利用 if...else if...else 判斷式, 判斷兩個數可能的關係: a>b , a=b , a<b
作者:
張凱翔
時間:
2015-7-4 09: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;
}
複製代碼
作者:
張健勳
時間:
2015-7-4 09:36
#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;
}
複製代碼
作者:
陳德晉
時間:
2015-7-4 09:36
#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;
}
複製代碼
回復
1#
tonyh
作者:
徐煒博
時間:
2015-7-4 09:37
#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;
}
複製代碼
作者:
蔡庚霖
時間:
2015-7-4 09:37
#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;
}
複製代碼
作者:
余洋毅
時間:
2015-7-4 09:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"Please Enter a:";
cin>>a;
cout<<"Please Enter 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;
}
複製代碼
作者:
洪煒庭
時間:
2015-7-4 09:44
#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;
}
複製代碼
作者:
蔡季樺
時間:
2015-7-4 09:50
#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;
}
複製代碼
作者:
吳承志
時間:
2015-7-4 09:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout<<"Please Enter";
cin>>a;
cout<<"Please Enter";
cin>>b;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
if(a>b)
{
cout<<"a is greater thah b"<<endl;
}
else if(a<b)
{
cout<<"a is smaller than b"<<endl;
}
else
{
cout<<"a is equal to b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
蔡秉宏
時間:
2015-7-4 09:51
#include<iostream>
#include<cstdlib>
using namespace std;
:lol
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;
}
複製代碼
作者:
錢建樺
時間:
2015-7-4 09:54
#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;
}
複製代碼
作者:
蔡庚霖
時間:
2015-7-4 11: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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2