-
Notifications
You must be signed in to change notification settings - Fork 0
/
wagemax.cpp
76 lines (75 loc) · 1.51 KB
/
wagemax.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <bits/stdc++.h>
using namespace std;
/*Informations
This program is created by XiaoYi Zero on ASUS Vivobook Pro 16
You can FREELY spread it base on GNU Public License.
Powered by XiaoYi Zero OpenSource Software Movement.
*/
int maxab(int a,int b)
{
if(a>b) return a;
else return b;
}
int main()
{
int person[5][5];
int i=0, j=0;
int imax, jmax, wagemax;
bool exit;
while(exit==0)
{
cout<<"person["<<i<<"]["<<j<<"]"<<"=";
cin>>person[i][j];
if(j<=3) j++;
if((j==4)&&(i<4))
{
i++;
j=0;
}
if((j==4)&&(i==4)) //达到最后一个值,退出
{
exit=1;
}
}
i=0;
j=0;
exit=0;
while(exit==0)
{
person[i][4]=person[i][1] + person[i][2] + person[i][3];
if(i<5) i++;
if(i==5) exit=1;
}
i=0;
j=0;
exit=0;
while(exit==0)
{
if(i==0)
{
wagemax=person[0][4];
i=1;
imax=0;
}
if((i>=1)&&(i<5))
{
wagemax=maxab(wagemax , person[i][4]);
i++;
}
if(i==5)
{
i=0;
while(exit==0)
{
if(wagemax==person[i][4])
{
exit=1;
imax=i;
}
else i++;
}
}
}
cout<<"The maxium of wage is person "<<person[imax][0]<<" whose wage is "<<wagemax;
return 0;
}