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

为什么run time error 啊?求救!!大虾帮忙!!

Posted by 00448167 at 2005-05-09 20:30:14 on Problem 1026
#include<iostream>
#include<string>

using namespace std;
void main()
{    
	int n,k1,k2,i,j;
	int * ptr;
	string s1,s2,s3,s4;
	cin>>n;
	while(n!=0){
		ptr = new int [n];

		for(i=0;i<n;i++)
			cin>>ptr[i];
		cin>>k1;
		cin.get();
		getline(cin,s1);
		cin>>k2;
		cin.get();
		getline(cin,s2);
       
		if(s1.length()<n)
			s1.resize(n);
		if(s2.length()<n)
			s2.resize(n);

		s3=s1;
		for(j=0;j<k1;j++){
			for(i=0;i<s1.length();i++){
			    s3[ptr[i]-1]=s1[i];
			}
			s1=s3;
		}

		s4=s2;
		for(j=0;j<k2;j++){
		    for(i=0;i<s2.length();i++)
			    s4[ptr[i]-1]=s2[i];
			s2=s4;
		}

		for(i=0;i<s3.length();i++)
			cout<<s3[i];
		cout<<endl;

		for(i=0;i<s4.length();i++)
			cout<<s4[i];
		cout<<endl;
		cout<<endl;
		cin>>n;
		cin>>n;
	}
	delete []ptr;
}

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