参考代码:
#include using namespace std; struct nodea{ int id,w; } a[100005];struct nodeb{ int id,w; }b[100005]; bool cmp1(nodea a,nodea b){ if(a.w != b.w) return a.w < b.w; else return a.id < b.id; } bool cmp2(nodeb a,nodeb b){ if(a.w != b.w) return a.w > b.w; else return a.id < b.id; } int main(){ int n1,n2; cin >> n1 >> n2; for(int i = 1; i > a[i].w, a[i].id = i; for(int i = 1; i > b[i].w, b[i].id = i; sort(a+1,a+n1+1,cmp1); sort(b+1,b+n2+1,cmp2); string s; cin >> s; int idx1 = 1,idx2 = 1; for(int i=0;i<s.length();i++){ if(s[i] == '1'){ cout << "B"; cout << b[idx1++].id << endl; } else{ cout << "A"; cout << a[idx2++].id << endl; } } cout << "E" << endl; return 0; }
0.0分
1 人评分
printf基础练习2 (C语言代码)浏览:305 |
printf基础练习2 (C语言代码)浏览:941 |
淘淘的名单 (C语言代码)浏览:1096 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:624 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:349 |
母牛的故事 (C语言代码)浏览:1427 |
1011题解浏览:760 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:560 |
1024题解浏览:806 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:484 |