標題:
if...else if...else 判斷式
[打印本頁]
作者:
tonyh
時間:
2016-1-23 09:29
標題:
if...else if...else 判斷式
本帖最後由 tonyh 於 2016-1-23 09:48 編輯
#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";
}else if(a<b)
{
cout<<"a<b";
}else
{
cout<<"a=b";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃茂勛
時間:
2016-1-23 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";
}else if(a<b)
{
cout<<"a<b";
}else
{
cout<<"a=b"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李啟綸
時間:
2016-1-23 09:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a, b;
cout<<"please enter a:";
cin>>a;
cout<<"please enter b:";
cin>>b;
if(a>b)
{
cout<<"a>b"<<endl;
}else if(a<b)
{
cout<<"a<b"<<endl;
}else
{
cout<<"a=b"<<endl;
}
cout<<endl;
system("pause");
}
複製代碼
作者:
洪億承
時間:
2016-1-23 09:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
if(a>b)
{
cout<<"a>b";
}else if(a<b)
{
cout<<"a<b"
}else
{
cout<<"a=b"
}
cout<<endl;
system("pause")
return 0;
}
複製代碼
作者:
任立宇
時間:
2016-1-23 09:41
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int b,c;
cout<<"輸入b:";
cin>>b;
cout<<"輸入c:";
cin>>c;
cout<<"b="<<b<<endl;
cout<<"c="<<c<<endl;
if(b>c)
{
cout<<"b大於c"<<endl;
}
else if(b<c)
{
cout<<"b小於c"<<endl;
}
else
{
cout<<"b等於c"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
潘彥勳
時間:
2016-1-23 09:43
#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";
}else if(a<b)
{
cout<<"a<b";
}else
{
cout<<"a=b";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陸長辰
時間:
2016-1-23 09:44
#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";
}else if(a<b)
{
cout<<"a<b";
}else if(a=b)
{
cout<<"a=b";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
巫沛庭
時間:
2016-1-23 09:44
#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";
}else if(a<b)
{
cout<<"a<b";
}else
{
cout<<"a=b";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
龔承緯
時間:
2016-1-23 09:45
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a, b;
cout<<"please enter a:";
cin>>a;
cout<<"please enter b:";
cin>>b;
if(a>b)
{
cout<<"a>b"<<endl;
}else if(a<b)
{
cout<<"a<b"<<endl;
}else
{
cout<<"a=b"<<endl;
}
cout<<endl;
system("pause");
}
複製代碼
作者:
巫晉宇
時間:
2016-1-23 09:51
#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