| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
直接用 string 模拟不行吗? 题目还有什么特殊意思吗#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator