#16082: C++ 答


love1245672@gmail.com (李奧尿多)

學校 : 大甲國中
編號 : 88384
來源 : [114.137.14.241]
最後登入時間 :
2020-08-02 14:21:35
a449. 國王烏龜的接駁車 -- USACO1996Problem setter: ATPTIOJ 1623 | From: [42.72.115.74] | 發表日期 : 2018-11-17 22:48

#include<iostream>
using namespace std;
int main()
{
int n, k, m;
while (cin >> n >> k >> m)
{
int *turtle = new int[n];
for (int i = 0; i < n; i++)
cin >> turtle[i];

for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (turtle[i] > turtle[j])
swap(turtle[i], turtle[j]);

int totalw = k * m;
int num = -1;
for (int i = 0; totalw >= 0; i++, num++)
{
totalw -= turtle[i];
}
cout << num << "\n";

system("pause");
}


}

 
#16104: Re:C++ 答


Aaaaaaaaaaaaa (羅傑)

學校 : 臺北市立大同高級中學
編號 : 69102
來源 : [111.235.208.242]
最後登入時間 :
2023-09-13 09:02:41
a449. 國王烏龜的接駁車 -- USACO1996Problem setter: ATPTIOJ 1623 | From: [203.72.178.252] | 發表日期 : 2018-11-21 17:12

#include
using namespace std;
int main()
{
int n, k, m;
while (cin >> n >> k >> m)
{
int *turtle = new int[n];
for (int i = 0; i < n; i++)
cin >> turtle[i];

for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (turtle[i] > turtle[j])
swap(turtle[i], turtle[j]);

int totalw = k * m;
int num = -1;
for (int i = 0; totalw >= 0; i++, num++)
{
totalw -= turtle[i];
}
cout << num << "\n";

system("pause");
}


}

system("pause");這個程式碼不能用


改成return 0;會NA吧?

 
ZeroJudge Forum