fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. /* int numbers[13] = {1, 15, 7, 3, 8, 8, 19, 5, 12, 8, 2, 6, 8}; */
  6. int numbers[13] = {1, 15, 8, 8, 8, 8, 7, 3, 19, 5, 12, 2, 6};
  7.  
  8. int counter = 1;
  9. int index = 0;
  10. int prev, next;
  11. int length = sizeof(numbers)/sizeof(int);
  12.  
  13. if (length > 0) {
  14. prev = numbers[index++];
  15. }
  16.  
  17. while (index < length && counter < 4) {
  18. next = numbers[index++];
  19. if (prev == next) counter++;
  20. else {
  21. counter = 1;
  22. prev = next;
  23. }
  24. }
  25.  
  26. if (counter == 4)
  27. printf("Found four times repeated number");
  28. else
  29. printf("No four times repeated number found");
  30.  
  31. return 0;
  32.  
  33. }
Success #stdin #stdout 0.01s 1676KB
stdin

stdout
Found four times repeated number