Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int max(int a, int b);
- int max(int a, int b)
- {
- if(a > b)
- {
- return a;
- }
- return b;
- }
- int main(void)
- {
- FILE* fin;
- int ans = 0, cnt = 0, prev, cur;
- if((fin = fopen("in.txt", "rt")) == NULL)
- {
- printf("Cant open file\n");
- }
- if(fscanf(fin, "%d", &prev) != 1)
- {
- printf("wrong file format");
- }
- while(fscanf(fin, "%d", &cur) == 1)
- {
- if(prev == cur)
- {
- cnt++;
- }
- else
- {
- ans = max(ans, cnt);
- cnt = 0;
- }
- prev = cur;
- }
- ans = max(ans, cnt);
- ans++;
- fclose(fin);
- printf("%d\n", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement