標題:
if...else if...else 判斷式
[打印本頁]
作者:
tonyh
時間:
2016-7-14 13:42
標題:
if...else if...else 判斷式
本帖最後由 tonyh 於 2016-7-14 14:24 編輯
[attach]1666[/attach]
[attach]1667[/attach]
[attach]1668[/attach]
#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-7-14 14:19
#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-7-14 14:20
#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-7-14 14:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int yee, eey;
cout<<"請輸入yee";
cin>>yee;
cout<<"請輸入eey";
cin>>eey;
if(yee>eey)
{
cout<<"yee>eey"<<endl;
}else if(yee<eey)
{
cout<<"yee<eey"<<endl;
}else
{
cout<<"yee=eey"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
袁士桓
時間:
2016-7-14 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;
複製代碼
作者:
曾彥翔
時間:
2016-7-14 14:25
回復
1#
tonyh
#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-7-14 14: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;
cout<<"a>b"<<endl;
}else 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-7-14 14:26
#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-7-14 14:26
{:2_27:} [code]#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;
}
複製代碼
[/code]
作者:
蔡幸融
時間:
2016-7-14 14:27
回復
9#
蔡幸融
作者:
蔡茿后
時間:
2016-7-14 14: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;
}
複製代碼
作者:
留騏民
時間:
2016-7-14 14:31
作者:
康睿群
時間:
2016-7-14 14:32
#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
{
複製代碼
作者:
康睿群
時間:
2016-7-14 14:33
作者:
康紘嘉
時間:
2016-7-14 14:33
#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-7-14 14:37
#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-7-14 15:03
#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
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2