残月封尘 @ 2018-11-21 12:25:12
using namespace std; int n,m,s[305][305],sum,maxx,num,mum; int main() { cin>>n; for(int i=1; i<=n; i++) { cin>>s[i][2]>>s[i][3]>>s[i][4]; s[i][5]=s[i][2]+s[i][3]+s[i][4];s[i][1]=i; } for(int i=1; i<=n; i++) { for(int j=i+1; j<=n; j++) { if(s[i][4]>s[j][5] || (s[i][5]==s[j][5] && s[i][1]<s[j][1] )|| (s[i][5]==s[j][5] && s[i][1]==s[j][1] &&s[i][0]>s[j][0])) { swap(s[i][0],s[j][0]);
}
}
}
return 0;
} /* 6 90 67 80 87 66 91 78 89 91 88 99 77 67 89 64 78 89 98
6 265 4 264 3 258 2 244 1 237 */
by Victorique_De_Blois @ 2018-11-21 12:30:07
by 2018小绿 @ 2018-11-21 12:30:47
希望更丰富的展现?使用Markdown
by sss7020 @ 2018-11-21 12:35:37
include<bits/stdc++.h>
using namespace std;
int n,m,s[305][305],sum,maxx,num,mum;
int main() {
cin>>n;
for(int i=1; i<=n; i++) {
cin>>s[i][2]>>s[i][3]>>s[i][4];
s[i][5]=s[i][2]+s[i][3]+s[i][4];s[i][1]=i;
}
for(int i=1; i<=n; i++) {
for(int j=i+1; j<=n; j++) {
if(s[i][4]>s[j][5] || (s[i][5]==s[j][5] && s[i][1]<s[j][1] )|| (s[i][5]==s[j][5] && s[i][1]==s[j][1] &&s[i][0]>s[j][0])) {
swap(s[i][0],s[j][0]);
}
}
}
return 0;
}
好心markdown
结构体呢?
by fengyucan @ 2019-09-08 09:56:14
希望更丰富的展现?使用Markdown