Advertisement
wojiaocbj

C6-D

Apr 6th, 2023
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. /*
  2.  Author: 曹北健(37509)
  3.  Result: AC Submission_id: 5340113
  4.  Created at: Thu Apr 06 2023 20:52:50 GMT+0800 (China Standard Time)
  5.  Problem: 6820  Time: 3 Memory: 1556
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <math.h>
  12. #include <ctype.h>
  13. #include <time.h>
  14. #pragma warning(disable:4996 6031)
  15. int main(){
  16. #ifdef _DEBUG
  17.     freopen("../../input.txt", "r", stdin);
  18. #endif // _DEBUG
  19.     char a[512] = { 0 }, b[512] = { 0 };
  20.     gets(a);
  21.     gets(b);
  22.     char *p = a;
  23.     int l = strlen(b);
  24.     for(;;){
  25.         p = strstr(p, b);
  26.         if(p){
  27.             printf("%d-%d\n", p - a, p - a + l - 1);
  28.             p += l;
  29.         }
  30.         else{
  31.             break;
  32.         }
  33.     }
  34. #ifdef _DEBUG
  35.     freopen("CON", "r", stdin);
  36.     system("pause");
  37. #endif // _DEBUG
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement