uuuuuuu000 @ 2024-04-24 22:58:11
#include<iostream>
using namespace std;
void swap_a(int a[100][4], int i, int j)
{
int t = 0;
for (int count = 0; count < 4; count++)
{
t = a[i][count];
a[i][count] = a[j][count];
a[j][count] = t;
}
return;
}
int sum(int a[100][4], int i)
{
int sum = 0;
for (int j = 0; j < 3; j++)
{
sum += a[i][j];
}
return sum;
}
void ord_a(int a[100][4], int n)
{
int sum1, sum2;
for (int i = 0; i < n; i++)
{
sum1 = sum(a, i);
for (int j = i + 1; j < n; j++)
{
sum2 = sum(a, j);
if (sum2 == sum1)
{
if (a[i][3] > a[j][3])
{
swap_a(a, i, j);
}
}
if (sum2 > sum1)
{
swap_a(a, i, j);
sum1 = sum2;
}
}
}
return;
}
int main()
{
int n;
while (cin >> n)
{
int a[100][4];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 3; j++)
{
cin >> a[i][j];
}
a[i][3] = i + 1;
}
ord_a(a, n);
for (int i = 0; i < n; i++)
{
cout << a[i][3] << " " << sum(a, i) << endl;
if (i == 4)
{
break;
}
}
}
return 0;
}
by uuuuuuu000 @ 2024-04-24 22:58:56
RE求助