Board logo

標題: 二數中找出較大的數 [打印本頁]

作者: tonyh    時間: 2013-5-4 15:17     標題: 二數中找出較大的數

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a, b, bigger;
  7.     cout<<"請輸入第一個數: ";
  8.     cin>>a;
  9.     cout<<"請輸入第二個數: ";
  10.     cin>>b;
  11.     bigger=(a>b)?a:b;    //a>b如果成立,則bigger的值為a,否則為b
  12.     cout<<"兩數中較大的數為"<<bigger<<endl;
  13.     system("pause");   
  14.     return 0;
  15. }
複製代碼

作者: 張瀚仁    時間: 2013-5-4 15:18

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a,b,bigger;
  7.     cout<<"請輸入第一個數: "<<endl;
  8.     cin>>a;
  9.     cout<<"請輸入第二個數: "<<endl;
  10.     cin>>b;
  11.     bigger=(a>b)?a:b;
  12.     cout<<"兩數中最大的數為"<<bigger<<endl;
  13.     system("pause");   
  14.     return 0;
  15. }
複製代碼

作者: 林以諾    時間: 2013-5-4 15:18

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a, b ,bigger;
  7.     cout<<"請輸入第一個數:";
  8.     cin>>a;
  9.     cout<<"請輸入第二個數:";
  10.     cin>>b;
  11.     bigger=(a>b)?a:b;
  12.     cout<<"兩數中較大的數為:"<<bigger<<endl;   
  13.     system("pause");
  14.     return 0;   
  15. }
複製代碼

作者: 劉泳鱔    時間: 2013-5-4 15:21

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a,b, bigger;
  7.     cout<<"請輸入第一個數: ";
  8.     cin>>a;
  9.     cout<<"請輸入第二個數: ";
  10.     cin>>b;
  11.     bigger=(a>b)?a:b;
  12.     cout<<"兩數中最大的為"<<bigger<<endl;
  13.     cout<<endl;
  14.     system("pause");
  15.     return 0;
  16. }
複製代碼

作者: 黃柏維    時間: 2013-5-4 15:21

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6. int a,b,bigger;
  7. cout<<"請輸入第一個數: ";
  8. cin>>a;
  9. cout<<"請輸入第二個數: ";
  10. cin>>b;
  11. bigger=(a>b)?a:b;
  12. cout<<"兩數中最大的質為: "<<bigger<<endl;   
  13. system("pause");
  14. return 0;   
  15. }
複製代碼

作者: 黃崇維    時間: 2013-5-4 15:27

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a, b, bigger;
  7.     cout<<"請輸入第一個數:";
  8.     cin>>a;
  9.     cout<<"請輸入第二個數:";
  10.     cin>>b;
  11.     bigger=(a>b)?a:b;
  12.     cout<<"兩數中最大的數為"<<bigger<<endl;
  13.     system("pause");
  14.     return 0;
  15. }        
複製代碼

作者: 蘇昱安    時間: 2013-5-4 15:29

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a, b, bigger;
  7.     cout<<"請輸入第一個數: ";
  8.     cin>>a;
  9.     cout<<"請輸入第二個數: ";
  10.     cin>>b;
  11.     bigger=(a>b)?a:b;   
  12.     cout<<"兩數中較大的數為"<<bigger<<endl;
  13.     system("pause");   
  14.     return 0;
  15. }
複製代碼

作者: 許逸群    時間: 2013-6-10 19:42

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   int x, y, bigger;
  7.   cout<<"請輸入一個數: ";
  8.   cin>>x;
  9.   cout<<"請輸入二個數: ";
  10.   cin>>y;
  11.   bigger=(x>y)?x:y;
  12.   cout<<"兩數中較大的數為: "<<bigger<<endl;   
  13.   system("pause");
  14.   return 0;     
  15. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2