返回列表 發帖
本帖最後由 駱顗安 於 2020-6-11 17:05 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a,b,c,d,e;
  7.     cout<<"請依序輸入三個數:";
  8.     cin>>a>>b>>c;
  9.     cout<<endl;
  10.     cout<<"三數中數字最大的為";
  11.     d=a>b?a:b;
  12.     e=c>d?c:d;
  13.     cout<<e;
  14.     system("pause");
  15.     return 0;
  16. }
複製代碼
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a,b,c;
  7.     cout<<"請依序輸入三個數:";
  8.     cin>>a>>b>>c;
  9.     cout<<endl;
  10.     cout<<"三數中數字最大的為";
  11.          for(int m=a+b+c;m>=0;m-=1)
  12.          if(m==a)
  13.          {
  14.                  cout<<a;
  15.                  m=0;
  16.          }
  17.          else if(m==b)
  18.          {
  19.                 cout<<b;
  20.                  m=0;
  21.          }
  22.          else if(m==c)
  23.          {
  24.                  cout<<c;
  25.                  m=0;
  26.          }
  27.     system("pause");
  28.     return 0;
  29. }
複製代碼

TOP

返回列表