Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void scan(int x[], int y[], int &last)
- {
- int tot = 0, tot2 = 0, i;
- int k = last;
- int finish;
- for (i = 0; i < 18; i++)
- {
- if (x[i] == tot)
- {
- y[k] = tot;
- tot = 0;
- k++;
- i++;
- finish = i;
- }
- tot += x[i];
- }
- for (i = finish; i < 18; i++)
- {
- tot2 += x[i];
- }
- y[k] = tot2;
- k++;
- last = k;
- }
- void main()
- {
- int x[] = { 20,30,50,140,50,10,200,40,70,110,35,40,5,20,100,30,2,8 };
- int y[5];
- int last = 0;
- scan(x, y, last);
- for (int i = 0; i < 5; i++)
- {
- cout << y[i] << " , ";
- }
- cout << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement