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