Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. FILE* fp;
  6. fp = fopen("testdata.in", "r");
  7.  
  8. int testcase;
  9. fscanf(fp, "%d", &testcase);
  10.  
  11. for(int tc = 1; tc<=testcase; tc++)
  12. {
  13. int count;
  14. int lightning;
  15. int seq, min, max;
  16. fscanf(fp, "%d %d %d", &seq, &min, &max);
  17.  
  18. for(int i = 0; i<seq; i++)
  19. {
  20. char bin;
  21. fscanf(fp, "%c", &bin);
  22. if(bin == '1') count++;
  23. if(bin == '0')
  24. {
  25. if(count<= max && count >= min)
  26. lightning++;
  27. }
  28. count = 0;
  29. }
  30. printf("Case #%d: %d\n", tc, lightning);
  31. }
  32. fclose(fp);
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement