標題:
if 判斷式 : 判斷數字大小
[打印本頁]
作者:
游東祥
時間:
2014-1-23 10:07
標題:
if 判斷式 : 判斷數字大小
[attach]816[/attach][attach]815[/attach]
[attach]814[/attach]
1. 輸入兩個數字至整數變數 a 與 b
2. 輸出 a 與 b
3. 輸出 a 與 b 的大小比較結果
作者:
劉得恩
時間:
2014-1-23 10:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
cout<<"請輸入a:";
cin>>a;
cout<< "請輸入b:";
cin>>b;
cout<<"a="<<a<<", b="<<b<<endl;
if(a>b)
cout<<"a大於b\n";
else if(a<b)
cout<<"a小於b\n" ;
else
cout<<"a等於b\n";
system("PAUSE");
return 0;
}
複製代碼
作者:
林宇翔
時間:
2014-1-23 10: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 << " 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;
}
複製代碼
作者:
李允軒
時間:
2014-1-23 10:08
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout << "請輸入a: ";
cin >> a;
cout << "請輸入b: ";
cin >> b;
cout << "a=" << a << "、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;
}
複製代碼
作者:
劉凱平
時間:
2014-1-23 10:08
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout <<"請輸入 :";
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; }
system("pause");
return 0;
}
複製代碼
作者:
黃詠軒
時間:
2014-1-23 10:08
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout << "請輸入a:";
cin >> a;
cout << "請輸入b:";
cin >> b;
cout << "a=" << a << ",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;
}
複製代碼
作者:
陳婉平
時間:
2014-1-23 10:09
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout <<"請輸入a:";
cin >> a;
cout <<"請輸入b:";
cin >> b;
cout <<"a =" <<a <<", 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;
}
複製代碼
作者:
任冠宇
時間:
2014-1-23 10:10
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<",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;
}
複製代碼
作者:
陳均
時間:
2014-1-23 10:10
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout <<"請輸入a:";
cin >>a;
cout <<"請輸入b:";
cin >>b;
cout <<"a="<< a <<",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;
}
複製代碼
作者:
黃國清
時間:
2014-1-23 10:12
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<",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;
}
複製代碼
作者:
劉凱平
時間:
2014-1-23 10:12
#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; }
system("pause");
return 0;
}
複製代碼
作者:
蔡維庭
時間:
2014-1-23 10:12
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout << "請輸入a:";
cin >> a;
cout << "請輸入b:";
cin >> b;
cout << "a=" << a << ",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;
}
複製代碼
作者:
朱俐蒨
時間:
2014-1-23 10:13
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<",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;
}
複製代碼
作者:
劉怡修
時間:
2014-1-23 10:15
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout<<"請輸入 a:";
cin >> a;
cout<<"請輸入 b:";
cin >> b;
cout<<" a = "<<a<<" 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;
}
複製代碼
作者:
郭品君
時間:
2014-1-23 10:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"a="<<a<<"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;
}
複製代碼
作者:
劉芝均
時間:
2014-1-23 10:21
#include <stream>
#include <cstdlib>
using namespace std ;
int main()
{
int a,b,;
cout << "請輸入a:";
cin >> a;
cout << "請輸入b:";
cin >> b;
cout << "a=" << a << ",b=" << b << endl;
if (a>b)
{
cout <<"a大於b" << endl;
}
else if (a<b)
{
cout <<"a 小於 " << endl;
}
else
{
cout <<"a 等於 " << endl;
}
system("pause");
return 0;
}
#include<iostream>
複製代碼
作者:
朱俐蒨
時間:
2014-1-23 11:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
int level;
cout<<"請輸入您的分數:";
cin>>score;
level= score / 10;
switch(level)
{
case 10:
case 9:
cout<<"A"<<endl;
break;
case 8:
cout<<"B"<<endl;
break;
case 7:
cout<<"C"<<endl;
break;
case 6:
cout<<"D"<<endl;
break;
default:
cout<<"E"<<endl;
break;
}
system("pause");
return 0;
}
複製代碼
作者:
劉凱平
時間:
2014-1-23 11:11
#include <iostream>
using namespace std;
int main()
{
int score;
int level;
cout<<"請輸入您的分數:";
cin>>score;
cout<<"score=="<<score<<endl;
level=score/10;
cout<<"您的評等是:";
switch(level)
{
case 10:
case 9:
cout<<"A"<<endl;
break;
case 8:
cout<<"B"<<endl;
break;
case 7:
cout<<"C"<<endl;
break;
case 6:
cout<<"D"<<endl;
break;
default:
cout<<"E"<<endl;
break;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2