| ||||||||||
| 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 | |||||||||
为什么定义全局变量不行? int a1,a2; ?????#include "stdio.h"
int opt[1001][1001];
char c1[1000],c2[1000];
int a1,a2;
int min(int a,int b,int c)
{
int t,t1;
t=a<b?a:b;
t1=c<t?c:t;
return t1;
}
int main()
{
int i,j;
opt[0][0]=0;
while(scanf("%d",&a1)!=EOF)
{
scanf("%s",c1);
scanf("%d",&a2);
scanf("%s",c2);
for(i=1;i<=a1;i++)
opt[i][0]=i;
for(j=1;j<=a2;j++)
opt[0][j]=j;
for(i=1;i<=a1;i++)
for(j=1;j<=a2;j++)
{
if(c1[i-1]==c2[j-1])
opt[i][j]=min(opt[i-1][j-1],opt[i-1][j]+1,opt[i][j-1]+1);
else
opt[i][j]=min(opt[i-1][j-1]+1,opt[i-1][j]+1,opt[i][j-1]+1);
}
printf("%d\n",opt[a1][a2]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator