Current location - Health Preservation Learning Network - Healthy weight loss - High reward! A water problem of ACM requires the use of structure, which must be adopted after passing.
High reward! A water problem of ACM requires the use of structure, which must be adopted after passing.
# include & ltiostream & gt

# include & ltcstdio & gt

# include & ltcstring & gt

# include & ltcmath & gt

# include & lt algorithm & gt

# include & ltcctype & gt

Use namespace std

Structural node

{

char name[30];

int num

int k; //input sequence

} s[ 1234];

Int cmp (node a, node b)

{

If (quantity = = quantity)

Return to a.k & ltb.k

Return to a.num & ltb.num

}

int main()

{

int n;

while(scanf("%d ",& ampn)! =EOF)

{

for(int I = 0; I & ltn;; i++)

{

scanf("%s %d ",s[i])。 Name & amps[i]. num);

s[i]。 k = I;

}

sort(s,s+n,CMP);

for(int I = 0; I & ltn;; i++)

printf("%s %d\n ",s[i]。 Name, s[i] num);

}

Returns 0;

}