fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int count_if(int n, int c, int v[]) {
  5. int acc = 0;
  6. for (int i = 0; i < c; i++) {
  7. if (n == v[i]) {
  8. acc++;
  9. }
  10. }
  11. return acc;
  12. }
  13.  
  14. int main(void) {
  15. int a[9] = {7, 6, 12, 8, 3, 5, 10, 9, 5};
  16. char s[5];
  17. printf("k: ");
  18. scanf("%4s%*[^\n]", s);
  19. int n = count_if(strtod(s, NULL), 9, a);
  20. if (n == 0) {
  21. printf("nothing!\n");
  22.  
  23. } else {
  24. printf("%d\n", n);
  25. }
  26. return EXIT_SUCCESS;
  27. }
  28.  
Success #stdin #stdout 0s 5424KB
stdin
Standard input is empty
stdout
k: nothing!