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=老--质价比的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 一年一循环
- 下一篇: SpringCloud(四) 微服务架构