Advertisement
Guest User

Ace String

a guest
Jan 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. int main()
  7. {
  8.     char tekst[99], ch, kopija[99], a, b, c, ch1;
  9.     int i = 0, povtoruvanje = 1, z = 0, j = 0;
  10.  
  11.     while(ch != '\n')
  12.     {
  13.         ch = getchar();
  14.         tekst[i] = ch;
  15.         if (isalpha(ch))
  16.         {
  17.             //printf("%c", ch);
  18.             if (ch >= 'A' && ch <= 'Z')
  19.             {
  20.                 if (povtoruvanje == 1 || povtoruvanje == 3)
  21.                 {
  22.                     if (povtoruvanje == 1)
  23.                     {
  24.                         a = ch;
  25.                         povtoruvanje = povtoruvanje + 1;
  26.                     }
  27.                     if (povtoruvanje == 3)
  28.                     {
  29.                         c = ch;
  30.                         kopija[z] = a;
  31.                         kopija[z+1] = b;
  32.                         kopija[z+2] = c;
  33.                         povtoruvanje = 1;
  34.                         z = z + 2;
  35.                     }
  36.                 }
  37.             }
  38.             else
  39.             {
  40.                 if (povtoruvanje == 2)
  41.                 {
  42.                     b = ch;
  43.                     povtoruvanje = povtoruvanje + 1;
  44.                 }
  45.             }
  46.         }
  47.         i++;
  48.     }
  49.     tekst[i] = '\0';
  50.  
  51.     while(ch != '\n')
  52.     {
  53.         ch1 = getchar();
  54.         kopija[i] = ch1;
  55.         j++;
  56.     }
  57.     kopija[j] = '\0';
  58.     printf("%s", kopija);
  59.  
  60.     //printf("%s", tekst);
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement