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 |
过路的大哥大姐,为什么老是run time error???#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator