標題:
025 三數字比大小
[打印本頁]
作者:
游東祥
時間:
2014-3-29 14:14
標題:
025 三數字比大小
輸入三個數字,比較大小後輸出結果。
作者:
林宇翔
時間:
2014-3-29 14:43
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a;
int b;
int c;
cout << "請輸入第一個數字:";
cin >> a;
cout << "請輸入第二個數字:";
cin >> b;
cout << "請輸入第三個數字:";
cin >> c;
if(a > b)
{
if( b > c)
{
cout << a << " > " << b << " > " << c << endl;
}
else if( b = c )
{
cout << a << " > " << b << " == " << c << endl;
}
}
if(b > a)
{
if( a > c)
{
cout << b << " > " << a << " > " << c << endl;
}
else if( a = c )
{
cout << b << " > " << a << " == " << c << endl;
}
}
if(a > c)
{
if( c > b)
{
cout << a << " > " << c << " > " << b << endl;
}
else if( c = b )
{
cout << a << " > " << c << " == " << b << endl;
}
}
if(c > a)
{
if( a > b)
{
cout << c << " > " << a << " > " << b << endl;
}
else if( a = b )
{
cout << c << " > " << a << " == " << b << endl;
}
}
if(b > c)
{
if( c > a)
{
cout << b << " > " << c << " > " << a << endl;
}
else if( c = a )
{
cout << b << " > " << c << " == " << a << endl;
}
}
if(c > b)
{
if( b > a)
{
cout << c << " > " << b << " > " << a << endl;
}
else if( b = a )
{
cout << c << " > " << b << " == " << a << endl;
}
}
if (a == b)
{
if( b > c)
{
cout << a << " == " << b << " > " << c << endl;
}
if( b < c)
{
cout << a << " == " << b << " < " << c << endl;
}
}
if (b == c)
{
if( c > a)
{
cout << b << " == " << c << " > " << a << endl;
}
if( c < a)
{
cout << b << " == " << c << " < " << a << endl;
}
}
if (a == c)
{
if( c > b)
{
cout << a << " == " << c << " > " << b << endl;
}
if( c < b)
{
cout << a << " == " << c << " > " << b << endl;
}
}
if (a == b && b == c)
{
cout << a << " == " << b << " == " << c << endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
李允軒
時間:
2014-3-29 14:43
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a;
int b;
int c;
cout << "請輸入第一個數字:";
cin >> a;
cout << "請輸入第二個數字:";
cin >> b;
cout << "請輸入第三個數字:";
cin >> c;
if (a > b)
{
if (b > c)
{
cout << a << ">" << b << ">" << c << endl;
}
else if (b == c)
{
cout << a << ">" << b << "=" << c << endl;
}
}
if (b > a)
{
if (a > c)
{
cout << b << ">" << a << ">" << c << endl;
}
else if (a == c)
{
cout << b << ">" << a << "=" << c << endl;
}
}
if (a > c)
{
if (c > b)
{
cout << a << ">" << c << ">" << b << endl;
}
else if (c == b)
{
cout << a << ">" << c << "=" << b << endl;
}
}
if (c > a)
{
if (a > b)
{
cout << c << ">" << a << ">" << b << endl;
}
else if (b == c)
{
cout << c << ">" << a << "=" << b << endl;
}
}
if (b > c)
{
if (c > a)
{
cout << b << ">" << c << ">" << a << endl;
}
else if (b == c)
{
cout << b << ">" << c << "=" << a << endl;
}
}
if (c > b)
{
if (b > a)
{
cout << c << ">" << b << ">" << a << endl;
}
else if (b == c)
{
cout << c << ">" << b << "=" << a << endl;
}
}
if (a == b)
{
if (b > c)
{
cout << a << "=" << b << ">" << c << endl;
}
else if (b < c)
{
cout << a << "<" << b << "=" << c << endl;
}
}
if (b == c)
{
if (b > a)
{
cout << b << "=" << c << ">" << a << endl;
}
else if (c < a)
{
cout << b << "<" << c << "=" << a << endl;
}
}
if (a == c)
{
if (c > b)
{
cout << a << "=" << c << ">" << b << endl;
}
else if (b < c)
{
cout << a << "<" << c << "=" << b << endl;
}
}
if (a == b && b == c)
{
cout << a << "=" << b << "=" << c << endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2