Advertisement
Malinovsky239

Untitled

Nov 11th, 2011
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. char s[1000], a[10000];
  7.  
  8. int foo(char c)
  9. {
  10.   if (c >= 'A' && c <= 'Z')
  11.     return (c - 'A' + 'a');
  12.   else
  13.     return c;
  14. }
  15. int main()
  16. {
  17.   int i, y, w, l1, l, z, k;
  18.   freopen("search.in", "r", stdin);
  19.   freopen("search.out", "w", stdout);
  20.   gets(s);
  21.   l = strlen(s);
  22.  
  23.   z = fread(a, 1, 2000, stdin);
  24.   a[z] = 0;
  25.   //printf("%d", z);
  26.   for ( i = 0; i < z; i++)
  27.   {
  28.     if (foo(a[i]) != foo(s[0]))
  29.       printf("%c", a[i]);
  30.     else
  31.     {
  32.       l1 = 0;
  33.       w = i;
  34.       for (y = 0; y < l; y++)
  35.       {
  36.         k = 0;
  37.         if (s[y] == ' ')
  38.         {
  39.           while (a[w + y] == ' ' || a[y + w] == 9 || a[w + y] == '\n')
  40.           {
  41.            //printf("%d %d ", a[w + y], w);
  42.             w++;
  43.           }
  44.           //y++;
  45.           w--;
  46.         }
  47.         if (foo(a[y + w]) == foo(s[y]))
  48.         {  
  49.           l1++;
  50.         }
  51.         else
  52.         {
  53.          // printf("[%c %c]", a[y + w] , s[y]);
  54.         }
  55.       }
  56.       //printf("%d", l1);
  57.       if (l1 == l)
  58.       {
  59.         printf("@");
  60.       }
  61.       printf("%c", a[i]);
  62.     }
  63.   }
  64. return 0;
  65.  
  66. }
  67.  
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement