Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

直接用 string 模拟不行吗? 题目还有什么特殊意思吗

Posted by dodowater at 2009-02-09 09:57:11 on Problem 2887
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string str,com,in;
	long index;
	int n,i;
	while( cin >> str )
	{
		scanf("%d",&n);
		while( n-- )
		{
			cin>>com;
			if( com == "Q")
			{
				cin>>index;
				cout<<str[index-1] << endl;
			}
			if( com == "I")
			{
				cin>>in>>index;
				if( index >= str.length() )
					index = str.length()+1 ;
				str.insert(index-1,in);
			}
		}
		str="";
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator