fork download
  1. #include <iostream>
  2. int main()
  3. {
  4. int A[10] = {}; // array of 10 zeroes
  5.  
  6. int index;
  7. while (std::cin >> index) // read index from stdin while not EOF
  8. A[index] += 1; // increment element at that index
  9.  
  10. // print array
  11. for (int i = 0; i != 10; ++i)
  12. std::cout << A[i];
  13. }
Success #stdin #stdout 0s 3344KB
stdin
1 2 3
stdout
0111000000