Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- char s[1000001];
- int n, ms;
- char line[1000001];
- int main()
- {
- scanf("%s", s);
- scanf("%d", &n);
- char temp;
- scanf("%c", &temp);
- while(n--)
- {
- fgets(line, sizeof(line), stdin);
- int ir;
- for(int i = 0; i < strlen(line); ++ i)
- {
- if(line[i] == ':')
- {
- ir = i;
- break;
- }
- }
- int match = -1;
- for(int i = ir + 1; i < strlen(line) - strlen(s); ++ i)
- {
- int cnt = 0;
- for(int j = 0; j < strlen(s); ++ j)
- {
- if(line[i + j] == s[j])
- {
- cnt++;
- }
- }
- if(cnt == strlen(s))
- {
- match = i - ir - 1;
- break;
- }
- }
- if(match != -1)
- {
- for(int i = 0; i < ir; i ++)
- {
- printf("%c", line[i]);
- }
- printf(": shift=%d\n", match);
- ms++;
- }
- }
- if(ms == 1)
- {
- printf("%d match found.\n", ms);
- }
- else
- {
- printf("%d matches found.\n", ms);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement