Advertisement
NazoKami

Untitled

May 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void formalize(char* s) {
  6.   if(s[strlen(s)-1]== 10) {
  7.     s[strlen(s)-1] = '\0';
  8.   }
  9. }
  10.  
  11. int main() {
  12.   char T[1000];
  13.   int Q=0;
  14.   char P[20];
  15.   fgets(P,20,stdin);
  16.   formalize(P);
  17.   while(true) {
  18.     fgets(T,100,stdin);
  19.     formalize(T);
  20.     if(strcmp(T,"#") == 0) {
  21.       break;
  22.     }
  23.     else {
  24.       while(strstr(T,P) != NULL) {
  25.     ++Q;
  26.     char* x = strstr(T,P);
  27.     *x = ' ';
  28.       }
  29.     }
  30.   }
  31.   printf("%d\n",Q);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement