Hello,
I have one task that i can't solve. I know that it's not hard compared to other task posted on this forum. I'm currently learning just in school so if someone can help that will be awesome :D btw im not speaking English, sry for grammar mistakes.
On ship, packages are transfering with given masses with
cart (capacity of cart is given and capacity is bigger or
equal to mass of packages). Beacuse of that packages can't be split.
When some package can't get into cart beacuse of current off
limit of cart capacity,we use new cart and put that
package in new cart .Write a program in C++ that shows in order,
for each cart , number of packages and total mass of packages
that were transfered with cart .
-Input
In first line is entering capacity of cart N (10 <= N <= 500).
In every other line enters mass of package M (1 <= M <= N) that needs
to be transfered. Input ends when we enter 0 (1 <= lines <= 50 000).
-Output
On first there's number of packages on cart and mass of packages
put on carts (separated by space), and then on last line serial
number of cart with biggest number of items.
For exaple:
-Input
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
30
5
10
8
12
3
5
15
13
5
15
2
4
22
9
0
|
-Output
1 2 3 4 5 6 7
|
3 23
3 20
2 28
4 26
1 22
1 9
4
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
int main(int argc, char const *argv[])
{
int n, x[500], s = 0;
int xt, array1[100], array2[100], array3[50];
cin >> n;
for(int i = 0; i <= n; i++){
cin >> x[i];
if(x[i] == 0) break;
}
do{
for (int i = 0; i <= x[i]; i++){
xt = x[i] + x[i+1];
if(xt >= 30){
array1[i] = xt - x[i-1]; //23
array3[0+i] = x[i-1];
array2[i] = array3[0+1]; //12
cout << array1[i] << endl;
}
}
}while(s == 0);
return 0;
}
|
my output is litteraly nothing..
thanks!