//1031
//题目的意思:给出n个人对m件T恤的满意度,按编号降序输出这m件T恤中综合满意度前k大的
#include<stdio.h>
#include<iostream>
#include<memory.h>
#include<algorithm>
using namespace std;
struct node
{
int pos;
double val;
}t[1111];
int cmp1(node a, node b)
{
return a.val > b.val;
}
int cmp2(node a, node b)
{
return a.pos > b.pos;
}
int main()
{
int n, m, k;
while (~scanf("%d%d%d",&n,&m,&k))
{
memset(t, 0, sizeof(t));
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m;j++)
{
t[j].pos = j;//记录设计元素编号
double d;
scanf("%lf", &d);
t[j].val += d;
scanf("%lf", &d);
t[j].val += d;
}
}
sort(t + 1, t + m + 1, cmp1);
sort(t + 1, t + k + 1, cmp2);
for (int i = 1; i <= k; i++)
{
printf("%d%c", t[i].pos, i == k ? '
' : ' ');
}
}
return 0;
}
//1038
/*思路:知道直径、圈数、时间,求路程和速度,主要是单位换算的问题
车轮转一圈所奏路程是车轮的周长C,就是PI*d=PI*2*r,那么转N圈所走的路程就是N*C
*/
#include<iostream>
#include<stdio.h>
#define PI 3.1415927
using namespace std;
int main()
{
float diameter;
int revolution;
float time;
float dis;
float speed;
int flag=0;
while (~scanf("%f%d%f", &diameter, &revolution, &time)&&(revolution!=0))
{
flag++;
dis = 0;
speed = 0;
dis = PI * diameter*revolution / (5280 * 12);//距离要转换为miles
time /= 3600;//时间要转换为小时
speed = dis / time;
printf("Trip #%d: %.2lf %.2lf
",flag,dis, speed);
}
return 0;
}
//1040
//思路:直接用sort函数进行升序
/*#include<iostream>
#include<algorithm>
#define N 1000
int num[N];
using namespace std;
int main()
{
int test;
int n;
int i;
while (cin>>test)
{
while (test--)
{
cin >> n;
for ( i = 0; i < n; i++)
{
cin >> num[i];
}
sort(num, num + n);
for ( i = 0; i < n; i++)
{
cout << num[i]<<' ';
}
cout << endl;
}
}
return 0;
}*/
//思路:自己写排序函数,当前的数组元素和后面的元素进行比较,如果比后面的某个元素大的话,则交换,也就是把大的那部分放到后面
#include<iostream>
#include<algorithm>
#define N 1000
int num[N];
using namespace std;
int main()
{
int test;
int n;
int i;
int j;
int temp;
while (cin>>test)
{
while (test--)
{
cin >> n;
for (i = 0; i < n; i++)
{
cin >> num[i];
}
for ( i = 0; i < n; i++)
{
for ( j = i; j < n; j++)
{
if (num[i]>num[j])
{
temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}
for ( i = 0; i < n; i++)
{
cout << num[i] << ' ';
}
cout << endl;
}
}
return 0;
}