# How to change the array to cycle correctly work?

The problem with sports programming
Condition:

tried to find something similar and found:

converted into a condition of my tasks
``````#include <iostream>
#include <fstream>
using namespace std;
int main(){
ofstream f2;

const int len = 2, string = 3;
const char ch = '\n';
char mass[len][strings];
int order[] = { 0, 1, 2, 1, 2, 1 }; ////

int i = 0;///
for(int r = 0; r<strings; r++) { fs.getline(mass[r], len-1,ch); Read lines into the array } for (int i="0;" mass[len][order[i % 6]]!="0;" i++) 6]]--; cout<< mass[len][0]<<mass[len][1]<< mass[len][2]<<endl; cout << endl; }< code></strings;></fstream></iostream>``````
```br><br> but gives me 3 blank lines and then zero.<br><br> Please help me to solve this problem```
June 10th 19 at 16:54
June 10th 19 at 16:56
Solution
The problem is solved without arrays and loops.
To begin to define how much time will be full bore L-s-P-s:
`N := min(A, int(B/2), C);`
The amount eaten by the time candy will be N*4. Let's see how many sweets will remain in vases:
``````A := AN; B := B-N*2; C := C-N;
N := N*4;``````

Determine at what point the vase is empty and add the candy eaten:
``````if A > 0 then
N := N+1;
if B > 0 then
N := N+1;
if C > 0 then
N := N+1;``````
#include
#include
#include
using namespace std;

int main()
{
ifstream fin("input.txt");
ofstream fin2("output.txt");

int order[] = { 0, 1, 2, 1, 2, 1 };
vases int[3];
int a,b,c;
fin>>a;
fin>>b;
fin>>c;
vases[0]=a;
vases[1]=b;
vases[2]=c;

int i;
for (i = 0; vases[order[i % 6]]!= 0; i++){
vases[order[i % 6]]--;
}
fin2< - karli.Kub commented on June 10th 19 at 16:59
this is for those who will encounter the same problem - karli.Kub commented on June 10th 19 at 17:02
First , you have a mistake. Under the terms of the task order must be {0, 1, 2, 1}. Secondly, you are sure to meet in a temporary restriction if the vases will be two million candy? - Kenyatta commented on June 10th 19 at 17:05

Find more questions by tags C++