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

大家帮忙看一下,怎么会WA啊

Posted by xtu6127 at 2006-07-30 17:52:16 on Problem 2887
#include <string.h>
#include <iostream>
using namespace std;

int main()
{
	char tt[1000]=" ", done, in, out[1000]=" ";
	int count, pos, size, k=0;
	cin>>tt;
	cin>>count;
	while(count>0)
	{
		cin>>done;
		size=strlen(tt);
		if(done=='I')
		{
			cin>>in>>pos;
			if(pos>size)
				tt[size]=in;
			else
			{
				for(int i=size;i>=pos;i--)
				tt[i]=tt[i-1];
				tt[pos-1]=in;
			}
		}
		else if(done=='Q')
		{
			cin>>pos;
			size=strlen(tt);
			if(pos<=size)
			{
               out[k]=tt[pos-1];
			   k++;
			}
		}
		count--;
	}
	for(int j=0;j<size;j++)
		cout<<out[j]<<endl;
	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