fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int mas [10000], n, i, j, a[10000];
  6. cin >> n;
  7. for (i = 0; i < n; i++)
  8. cin >> mas[i];
  9. for (i = 0; i < n; i = i + 3) {
  10. a [j] = mas [i];
  11. j++;
  12. }
  13. for (i = 0; i < j; i++)
  14. cout << a [i] << " ";
  15. }
Success #stdin #stdout 0.01s 5376KB
stdin
6
1 2 3 4 5 6
stdout
1 4