fork(1) download
  1. #include <iostream>
  2.  
  3. template <std::size_t N, std::size_t M>
  4. void normalizebyIndex(const int (&src)[N], int (&dest)[M])
  5. {
  6. for (std::size_t i = 0; i != M; ++i) {
  7. dest[i] = src[i * N / M];
  8. }
  9. }
  10.  
  11. int main()
  12. {
  13. const int a[5] = {0,0,1,0,1};
  14. int b[10]; //Normalized array by index
  15.  
  16. normalizebyIndex(a, b);
  17.  
  18. for (auto e : b) {
  19. std::cout << e;
  20. }
  21. std::cout << std::endl;
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
0000110011