Demo entry 6350206

2017056

   

Submitted by anonymous on Mar 08, 2017 at 01:25
Language: C++. Code size: 585 Bytes.

#include <stdio.h>
#define N 200
char str[N];
char op[50];
int main(int argc, char** argv) {
	int n;
	while(scanf("%s",str)!=EOF) {
		scanf("%d",&n);
		while(n--) {
			scanf("%s",op);
			char c=op[0];
			int start=op[1]-'0';
			int len=op[2]-'0';
			if(c=='0') {
				for(int i=start,j=start+len-1;i<j;i++,j--){
					char tmp;
					tmp=str[i];
					str[i]=str[j];
					str[j]=tmp;
				}
				printf("%s\n",str);
			}
			if(c=='1') {
				for(int i=3,j=start;j<start+len;i++,j++){
					str[j]=op[i];
				}
				printf("%s\n",str);
			}
		}
	}

	return 0;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).