Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main() {
  4.     int a;
  5.     int count = 0;
  6.     scanf("%d", &a);
  7.     int *mas = new int [a];
  8.     for (int i = 0; i < a; i++) {
  9.         scanf("%d", &mas[i]);
  10.     }
  11.     for (int i = 0; i < a; i++) {
  12.         if (mas[i] == 1) {
  13.             count = count + 1;
  14.         }
  15.     }
  16.     printf("\n%d\n", count);
  17.     int *masq = new int [count];
  18.     int j = 0;
  19.     for (int i = 0; i < a; i++) {
  20.         masq[j] = masq[j] + 1;
  21.         if (mas[i+1] == 1) {
  22.             j = j + 1;
  23.         }
  24.     }
  25.     for (int j = 0; j < count; j++) {
  26.         printf("%d ", masq[j]);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement