Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4. using namespace std;
  5. int main(int argc, char** argv) {
  6. char a[100] = "abbccc_hgg__kkk\0";
  7. int n;
  8. n = strlen(a);
  9. char choise;
  10. cin>> choise;
  11. if (choise=='p'){
  12. int k = 1;
  13. for (int i =1; i < n; i++)
  14. {
  15. if (a[i-1]!=a[i])
  16. k++;
  17. }
  18. int cur=0;
  19. int * el = new int[k];
  20. for (int i=0;i<k;i++)
  21. el[i]=0;
  22. for (int i=1;i<n;i++){
  23. if(a[i-1]==a[i])
  24. el[cur]++;
  25. else
  26. cur++;
  27. }
  28. for (int i=0;i<k;i++)
  29. el[i]++;
  30. cur=0;
  31. if (el[0]==1)
  32. cout<<a[0];
  33. else
  34. cout<<el[0]<<a[0];
  35. for (int i=1;i<n;i++){
  36. if(a[i-1]!=a[i]){
  37. cur++;
  38. if (el[cur]>1)
  39. cout<<el[cur]<<a[i];
  40. else
  41. cout<<a[i];
  42. }
  43. }
  44. }
  45. if (choise=='u'){
  46. for(int i=0;i<n;i++)
  47. if
  48. }
  49. return 0;
  50. }
  51.  
  52.  
  53. ДОДЕЛАТЬ!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement