#18120: 測試時AC,送出時WA


pigshitgod4444@gmail.com (王家彌)

學校 : 不指定學校
編號 : 92418
來源 : [203.204.34.7]
最後登入時間 :
2020-01-14 22:58:55
d659. 11727 - Cost Cutting -- UVa11727 | From: [119.14.45.81] | 發表日期 : 2019-06-17 20:38

我的C++ code如下:

 

#include <iostream>
#include <list>
using namespace std;

int main()
{
int num;
cin >> num;
int salary[num];
int sala;
list<int> lst;
list<int>::iterator it;
int count = 0;
while (count < num) {
for (int i=1;i<=3;i++) {
cin >> sala;
lst.push_back(sala);
}
lst.sort();
lst.pop_front();
lst.pop_back();
for (it = lst.begin();it != lst.end();it++) {
salary[count] = *it;
}
while (!lst.empty()) {
lst.pop_back();
}
count++;
}
for (int i=0;i<3;i++) {
cout << "Case " << i+1 << ": " << salary[i] << endl;
}

return 0;
}

請問哪邊出錯了?

 
#18129: Re:測試時AC,送出時WA


rexwu1104@gmail.com (黑雪公主 Black Lotus)

學校 : 新北市私立南山高級中學
編號 : 93041
來源 : [118.166.54.130]
最後登入時間 :
2022-06-06 20:48:09
d659. 11727 - Cost Cutting -- UVa11727 | From: [114.24.4.158] | 發表日期 : 2019-06-18 17:06

我的C++ code如下:

 

#include
#include
using namespace std;

int main()
{
int num;
cin >> num;
int salary[num];
int sala;
list lst;
list::iterator it;
int count = 0;
while (count < num) {
for (int i=1;i<=3;i++) {
cin >> sala;
lst.push_back(sala);
}
lst.sort();
lst.pop_front();
lst.pop_back();
for (it = lst.begin();it != lst.end();it++) {
salary[count] = *it;
}
while (!lst.empty()) {
lst.pop_back();
}
count++;
}
for (int i=0;i<3;i++) {
cout << "Case " << i+1 << ": " << salary[i] << endl;
}

return 0;
}

請問哪邊出錯了?

希望有幫上忙(解題報告)


 
ZeroJudge Forum