Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main ()
- {
- char str[1025] = {0};
- scanf("%[^\n]",str);
- int n;
- scanf("%d",&n);
- for(int i=0;i<n;i++)
- {
- char instruction[100];
- scanf("\n%s",instruction);
- if(instruction[0]=='P')
- {
- printf("%s\n",str);
- }
- if(instruction[0]=='R'&&instruction[2]=='V')
- {
- int length=0;
- while(1)
- {
- if(str[length]=='\0')
- {
- length=length-1;
- break;
- }
- else length++;
- }
- int i=0;
- int newstr[1025]={0};
- for(int j=length;j>=0;j--)
- {
- printf("%c",str[j]);
- newstr[i]=str[j];
- i++;
- }
- printf("\n");
- newstr[i+1]='\0';
- for(int i=0;newstr[i]!='\0';i++)
- {
- str[i]=newstr[i];
- }
- }
- if(instruction[3]=='L')
- {
- for(int i=0;str[i]!='\0';i++)
- {
- if(str[i]>='A'&&str[i]<='Z')
- {
- str[i]+=32;
- }
- }
- for(int i=0;str[i]!='\0';i++)
- {
- printf("%c",str[i]);
- }
- printf("\n");
- }
- if(instruction[3]=='U')
- {
- for(int i=0;str[i]!='\0';i++)
- {
- if(str[i]>='a'&&str[i]<='z')
- {
- str[i]-=32;
- }
- }
- for(int i=0;str[i]!='\0';i++)
- {
- printf("%c",str[i]);
- }
- printf("\n");
- }
- if(instruction[0]=='R'&&instruction[2]=='M')
- {
- char c;
- scanf("%c",&c);
- scanf("%c",&c);
- int j=0;
- for(int i=0;str[i]!='\0';i++)
- {
- if(str[i]!=c)
- {
- printf("%c",str[i]);
- str[j]=str[i];
- j++;
- }
- }
- printf("\n");
- str[j]='\0';
- }
- if(instruction[0]=='C')
- {
- char string[1025]={0};
- int new=0;
- for(int i=1,number=1;;i++)
- {
- if(str[i]==str[i-1]) number++;
- else
- {
- string[new++]='-';
- string[new++]=str[i-1];
- string[new++]=number+48;
- number=1;
- }
- if(str[i]=='\0')
- {
- break;
- }
- }
- string[new+1]='\0';
- for(int i=0;string[i]!='\0';i++)
- {
- printf("%c",string[i]);
- }
- printf("\n");
- for(int i=0;string[i]!='\0';i++)
- {
- str[i]=string[i];
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment