1001
2006-04-07 21:27
120 查看
#include <iostream.h>
int main(int argc, char* argv[])
{
int n,i,j,num[500],theme[500],temp;
while(cin>>n)
{
for(i=0;i<n;i++)
cin>>num[i]>>theme[i];
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
if(theme[j]<theme[j+1])
{
temp=theme[j];
theme[j]=theme[j+1];
theme[j+1]=temp;
temp=num[j];
num[j]=num[j+1];
num[j+1]=temp;
}
for(i=0;i<n;i++)
cout<<num[i]<<" "<<theme[i]<<endl;
}
return 0;
}
int main(int argc, char* argv[])
{
int n,i,j,num[500],theme[500],temp;
while(cin>>n)
{
for(i=0;i<n;i++)
cin>>num[i]>>theme[i];
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
if(theme[j]<theme[j+1])
{
temp=theme[j];
theme[j]=theme[j+1];
theme[j+1]=temp;
temp=num[j];
num[j]=num[j+1];
num[j+1]=temp;
}
for(i=0;i<n;i++)
cout<<num[i]<<" "<<theme[i]<<endl;
}
return 0;
}
相关文章推荐
- PAT-B 1001 害死人不偿命的(3n+1)猜想 (15)
- 1001 舒适的路线
- PAT 1001. A+B Format (20)(字符串转换)
- poj-1001 Exponentiation
- POJ 1001
- POJ 1001
- poj 1001 求高精度幂
- LightOj 1001 - Opposite Task (数值和的拆分)
- 1001. 害死人不偿命的(3n+1)猜想 (15)
- 2016ICPC青岛赛区网络赛 1001
- hdu 5878 I Count Two Three (2016 ACM/ICPC Asia Regional Qingdao Online 1001)
- PAT乙级1001
- HDU 5902 GCD is Funny(BestCoder #87 1001)
- Ubuntu 14.04刷机时报错_BROM ERROR : S_UNDEFINED_ERROR (1001)
- BZOJ 1001
- 求最大边/最小边的比值最小的路径 codevs 1001 舒适的路线
- 1001. 害死人不偿命的(3n+1)猜想 (15)
- 【codevs 1001】舒适的路线
- 1001. Printer Queue
- B-1001