- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main(){
- re:
- int a,b,c,d;
- cout<<"請依序輸入四個數:"<<endl;
- cin>>a>>b>>c>>d;
- if(a>b&&a>c&&a>d)
- cout<<"四數中最大的數為: "<<a<<endl;
- else if(b>a&&b>c&&b>d)
- cout<<"四數中最大的數為: "<<b<<endl;
- else if(c>a&&c>b&&c>d)
- cout<<"四數中最大的數為: "<<c<<endl;
- else if(d>a&&d>b&&d>c)
- cout<<"四數中最大的數為: "<<c<<endl;
- else
- cout<<"數字重複!"<<endl;
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |