標題:
if...else if...else 判斷式
[打印本頁]
作者:
tonyh
時間:
2017-2-4 13:39
標題:
if...else if...else 判斷式
本帖最後由 tonyh 於 2017-2-4 14:13 編輯
#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;
}
複製代碼
作者:
邵顯茗
時間:
2017-2-4 13:58
#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;
}
複製代碼
作者:
吳尚謙
時間:
2017-2-4 14:01
#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;
}
複製代碼
作者:
柯識一
時間:
2017-2-4 14:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x ,y;
cout<<"請輸入x:";
cin>>x;
cout<<"請輸入y:";
cin>>y;
cout<<"x="<<x<<endl;
cout<<"y="<<y<<endl;
if(x>y)
{
cout<<"x>y"<<endl;
}
else if(x<y)
{
cout<<"x<y"<<endl;
}
else
{
cout<<"x=y"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
吳宇翔
時間:
2017-2-4 14:05
#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;
}
複製代碼
作者:
張閎鈞
時間:
2017-2-4 14:07
#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;
}
複製代碼
作者:
曹瑈芠
時間:
2017-2-4 14:08
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a, z;
cout<<"請輸入a的值: ";
cin>>a;
cout<<"請輸入z的值: ";
cin>>z;
if(a<z)
{
cout<<"a小於z"<<endl;
}
else if (a>z)
{
cout<<"a大於z"<<endl;
}
else
{
cout<<"a等於z"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
吳孟軒
時間:
2017-2-4 14:11
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x;
int 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;
}
複製代碼
作者:
莊晉安
時間:
2017-2-4 14:13
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x;
int y;
cout<<"請輸入x:";
cin>>x;
cout<<"請輸入y:";
cin>>y;
cout<<"x="<<x<<endl;
cout<<"y="<<y<<endl;
if(x>y)
{
cout<<"X大於y"<<endl;
}
else if(x<y)
{
cout<<"X小於y"<<endl;
}
else
{
cout<<"X等於y"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
張凱婷
時間:
2017-2-4 14:14
#include<cstdlib>
using namespace std;
int main()
{
int a,z;
cout<<"請輸入a的值:";
cin>>a;
cout<<"請輸入z的值:";
cin>>z;
if(a<z)
{
cout<<"a小於z"<<endl;
}
else if(a>z)
{
cout<<"a大於z"<<endl;
}
else
{
cout<<"a等於z"<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2