#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");
}
}
#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吧?