浙江工业大学
cout<<c<<endl;................................................................................................................................14
cout<<endl;.......................................................................................................................................14
}........................................................................................................................................................14
return 0;............................................................................................................................................14
}.........................................................................................................................................................14
2387.Online Shopping.......................................................................................................................14
这题关键是读懂题目要求的排序规则。.......................................................................................14
#include<iostream>...........................................................................................................................14
#include<cmath>...............................................................................................................................14
#include <vector>..............................................................................................................................14
#include <algorithm>........................................................................................................................14
using namespace std;.........................................................................................................................14
int minj,d[5][5],a,b;...........................................................................................................................14
int least(int k,int j){...........................................................................................................................14
int tp1[5],tp2[5],g;............................................................................................................................14
for (g=0;g<b;g++) tp1[g]=d[k][g];...................................................................................................14
for (g=0;g<b;g++) tp2[g]=d[j][g];...................................................................................................14
sort(tp1,tp1+b);.................................................................................................................................14
sort(tp2,tp2+b);.................................................................................................................................14
for (g=0;g<b;g++){..........................................................................................................................14
if(tp1[g]>tp2[g])...............................................................................................................................14
return j;.............................................................................................................................................14
else if(tp1[g]<tp2[j]).........................................................................................................................14
return k;............................................................................................................................................14
}........................................................................................................................................................14
return k;............................................................................................................................................14
}.........................................................................................................................................................14
void xsort(){......................................................................................................................................14
int i,j,g,k,tp[5];..................................................................................................................................14
for (i=0;i<a;i++)...............................................................................................................................14
{........................................................................................................................................................14
k=i;....................................................................................................................................................14
for (j=i;j<a;j++)................................................................................................................................14
{........................................................................................................................................................14
if (d[k][minj]>d[j][minj]).................................................................................................................15
{........................................................................................................................................................15
k=j;....................................................................................................................................................15
}........................................................................................................................................................15
else if(d[k][minj]==d[j][minj]){......................................................................................................15
k=least(k,j);.......................................................................................................................................15
}........................................................................................................................................................15
}........................................................................................................................................................15
for (g=0;g<b;g++) tp[g]=d[i][g];......................................................................................................15
Tzjut009 第 3 页 2021-8-5