2873=老--质价比
生活随笔
收集整理的這篇文章主要介紹了
2873=老--质价比
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 #include <stdio.h>
2 #include <string.h>
3 struct node
4 {
5 int w,j;
6 } th[100],t;
7 int main()
8 {
9 int i,j,n;
10 while(scanf("%d",&n)!=EOF)
11 {
12 for(i=0; i<n; i++)
13 {
14 scanf("%d",&th[i].w);
15 }
16 for(i=0; i<n; i++)
17 {
18 scanf("%d",&th[i].j);
19 }
20 for(i=0; i<n; i++)
21 {
22 for(j=0; j<n-1-i; j++)
23 {
24 if(th[j].w>th[j+1].w)
25 {
26 t=th[j],th[j]=th[j+1],th[j+1]=t;
27 }
28 else if(th[j].w==th[j+1].w)
29 {
30 if(th[j].j<th[j+1].j)t=th[j],th[j]=th[j+1],th[j+1]=t;
31 }
32 }
33 }
34 for(i=0; i<n; i++)
35 {
36 printf("%d %d
",th[i].w,th[i].j);
37 }
38 }
39 return 0;
40 }
總結
以上是生活随笔為你收集整理的2873=老--质价比的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一年一循环
- 下一篇: 关于jmf不能播放mp3的问题解决