Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- #include <string>
- using namespace std;
- int main(int argc, char* argv[])
- {
- int wnum;
- cin >> wnum;
- char** tab = (char**)calloc(wnum,sizeof(char*));
- int j = 0;
- for (j; j < wnum; j++)
- {
- char* word = (char*)calloc(200, sizeof(char));
- scanf("%s", word);
- tab[j] = word;
- cout << tab[j]<<endl;
- }
- char** v = tab;
- char** newtab = (char**)calloc(j, sizeof(char*));
- for (int k = 0; k < wnum;k++)
- {
- char* p = *v;
- int len;
- char* tmptab = (char*)calloc(len=strlen(p)+1, sizeof(char));
- int tmp;
- int i=0;
- tmp = 0;
- for (i; i < len-2; i++)
- {
- int licznik = 0;
- if (p[i + 2] == p[i] && p[i + 1] == p[i])
- {
- char x = p[i];
- while (p[i] == x)
- {
- licznik++;
- i++;
- }
- i--;
- }
- tmptab[tmp] = p[i];
- tmp++;
- if (licznik)
- {
- tmptab[tmp] = licznik + 48;
- tmp++;
- }
- }
- tmptab[tmp++] = p[i++];
- tmptab[tmp] = p[i];
- v++;
- cout << tmptab<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement