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 suying at 2009-04-03 23:19:22 on Problem 3356
#include<iostream>
//#include<string.h>
using namespace std;
int min(int a,int b,int c)
{
	int min;
	if(a>b)
		min=b;
	else min=a;
	if(min>c)
		min=c;
	return min;
}
int main()
{
	char a[100],b[100];
	//string a,b;
	int lena,lenb,i,j;
	int array[100][100];
	while(cin>>lena>>a>>lenb>>b)
	{


	for(i=0;i<=lena;i++)
		array[i][0]=i;
	for(i=0;i<=lenb;i++)
		array[0][i]=i;
	for(i=1;i<=lena;i++)
	{
		for(j=1;j<=lenb;j++)
		{
			if(a[i-1]==b[j-1])
			{
				array[i][j]=min(array[i-1][j-1],array[i-1][j]+1,array[i][j-1]+1);
			}
			else
			{
				array[i][j]=min(array[i-1][j-1]+1,array[i-1][j]+1,array[i][j-1]+1);
			}
		}
	}
	cout<<array[lena][lenb]<<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