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

求助各位同学,PE到死就是过不去

Posted by 317358117 at 2011-05-03 11:05:18 on Problem 1026
交了不下10遍 次次PE,搞不清到底哪里除了问题。。太郁闷了|>_<|


#include<iostream>
using namespace std;

int main()
{
	int n,i,j,t,step[210][210],mod[210],next[210],ci;
	char in[210],out[210];
	while(cin>>n&&n)
	{
		for(i=1;i<=n;i++)
			cin>>next[i];
		memset(mod,0,sizeof(int)*210);
		memset(step,0,sizeof(int)*210*210);

		for(i=1;i<=n;i++)
		{
			j=i;
			do
			{
				j=next[j];
				step[i][++mod[i]]=j;
			}while(j!=i);
		}

		while(cin>>ci&&ci)
		{
			memset(out,' ',sizeof(out));
			getchar();
			gets(&in[1]);
			in[n+1]=out[n+1]='\0';

			for(i=1;in[i]!='\0';i++)
			{
				if(ci%mod[i]==0)
					out[i]=in[i];
				else
					out[step[i][ci%mod[i]]]=in[i];
			}
			
			for(i=strlen(&out[1]);out[i]==' ';i--)
				out[i]='\0';
			
			puts(&out[1]);
			cout<<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