fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. int main() {
  6. const int x[20] = {1,1,32,43,54,65,76,76,76,2,12,12,32,43,54,3,3,23,1,43};
  7.  
  8. for (int i=0;i<20;i++) {
  9. if (std::find(x, x + i, x[i]) != x + i) {
  10. continue;
  11. }
  12. const auto count = std::count(x + i, x + 20, x[i]);
  13. std::cout << "The number " << x[i] << " is repeated " << count << " times\n";
  14. }
  15. }
  16.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
The number 1 is repeated 3 times
The number 32 is repeated 2 times
The number 43 is repeated 3 times
The number 54 is repeated 2 times
The number 65 is repeated 1 times
The number 76 is repeated 3 times
The number 2 is repeated 1 times
The number 12 is repeated 2 times
The number 3 is repeated 2 times
The number 23 is repeated 1 times