---
title: "九度1177 查找"
author: "piperzero"
date: "2013-01-29T11:55:00Z"
tags: []
slug: "1177"
draft: false
lastmod: "2013-03-06T20:51:40Z"
id: 1825054
url: "https://piperzero.iteye.com/blog/1825054"
---

```
/*********************************
 *    日期：2013-1-29
 *    作者：SJF0115
 *    题号: 九度1177
 *    题目：查找
 *    来源：http://ac.jobdu.com/problem.php?pid=1177
 *    结果：AC
 *    题意：
 *    总结：
**********************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

char order[101],string[101];

//翻转
void Rotate(int index,int len){
	char temp;
	for(int i = 0;i < len/2;i++){
		temp = string[index+i];
		string[index+i] = string[index+len-1-i];
		string[index+len-1-i] = temp;
	}
}
//替换
void Replace(int index,int len){
	for(int i = 0;i < len;i++){
		string[index+i] = order[3+i];
	}
}
int main()
{
	int n,i,j;
	//freopen("C:\\Users\\SJF\\Desktop\\acm.txt","r",stdin);
	while(scanf("%s",string)!=EOF)
	{
		//命令个数
		scanf("%d",&n);
		//输入命令
		for(i = 0;i < n;i++){
			scanf("%s",order);
			int index = order[1]-'0',len = order[2]-'0';
			//翻转
			if(order[0] == '0'){
				Rotate(index,len);
			}
			//替换
			else if(order[0] == '1'){
				Replace(index,len);
			}
			//输出
			for(j = 0;j < strlen(string);j++){
				printf("%c",string[j]);
			}
			printf("\n");
		}
	}
	return 0;
}
```