Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- using namespace std;
- int main(int argc, char** argv) {
- char a[100] = "abbccc_hgg__kkk\0";
- int n;
- n = strlen(a);
- char choise;
- cin>> choise;
- if (choise=='p'){
- int k = 1;
- for (int i =1; i < n; i++)
- {
- if (a[i-1]!=a[i])
- k++;
- }
- int cur=0;
- int * el = new int[k];
- for (int i=0;i<k;i++)
- el[i]=0;
- for (int i=1;i<n;i++){
- if(a[i-1]==a[i])
- el[cur]++;
- else
- cur++;
- }
- for (int i=0;i<k;i++)
- el[i]++;
- cur=0;
- if (el[0]==1)
- cout<<a[0];
- else
- cout<<el[0]<<a[0];
- for (int i=1;i<n;i++){
- if(a[i-1]!=a[i]){
- cur++;
- if (el[cur]>1)
- cout<<el[cur]<<a[i];
- else
- cout<<a[i];
- }
- }
- }
- if (choise=='u'){
- for(int i=0;i<n;i++)
- if
- }
- return 0;
- }
- ДОДЕЛАТЬ!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement