Advertisement
piotrjanuszek

Untitled

Feb 7th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <iostream>
  4. #include <conio.h>
  5. #include <string>
  6.    
  7. using namespace std;
  8.    
  9. int main(int argc, char* argv[])
  10. {
  11.     int wnum;
  12.     cin >> wnum;
  13.     char** tab = (char**)calloc(wnum,sizeof(char*));
  14.     int j = 0;
  15.     for (j; j < wnum; j++)
  16.     {
  17.         char* word = (char*)calloc(200, sizeof(char));
  18.         scanf("%s", word);
  19.         tab[j] = word;
  20.         cout << tab[j]<<endl;
  21.     }
  22.     char** v = tab;
  23.     char** newtab = (char**)calloc(j, sizeof(char*));
  24.     for (int k = 0; k < wnum;k++)
  25.     {  
  26.         char* p = *v;
  27.         int len;
  28.         char* tmptab = (char*)calloc(len=strlen(p)+1, sizeof(char));
  29.         int tmp;
  30.         int i=0;
  31.         tmp = 0;
  32.         for (i; i < len-2; i++)
  33.         {
  34.             int licznik = 0;
  35.            
  36.             if (p[i + 2] == p[i] && p[i + 1] == p[i])
  37.             {
  38.                 char x = p[i];
  39.                 while (p[i] == x)
  40.                 {
  41.                     licznik++;
  42.                     i++;
  43.                 }
  44.                 i--;
  45.             }
  46.             tmptab[tmp] = p[i];
  47.             tmp++;
  48.             if (licznik)
  49.             {
  50.                 tmptab[tmp] = licznik + 48;
  51.                 tmp++;
  52.             }
  53.         }
  54.         tmptab[tmp++] = p[i++];
  55.         tmptab[tmp] = p[i];
  56.         v++;
  57.         cout << tmptab<<endl;
  58.     }
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement