| ||||||||||
| 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 | |||||||||
Re:动态规划 ,为什么会runtime error?高手期待中 数组越界基本不可能In Reply To:动态规划 ,为什么会runtime error?高手期待中 数组越界基本不可能 Posted by:lyl625760 at 2008-10-23 11:03:17 > #include<conio.h>
> #include<iostream>
> using namespace std;
>
>
> int main()
> {
>
> int n;
> cin>>n;
>
> int min[n][n];
> for (int i=0 ;i<n;i++)
> for(int j=0;j<n;j++)
> min[i][j]=0;
>
> string ss;
> cin>>ss;
>
> for(int i=n-2;i>=0;i--)
> for(int j=i+1;j<n;j++)
> {
> if(ss[i]==ss[j])
> min[i][j]=min[i+1][j-1];
> else
> min[i][j] = 1 + (min[i+1][j]<min[i][j-1] ? min[i+1][j]:min[i][j-1]);
> }
>
> cout<<min[0][n-1]<<endl;
>
>
> getch();
> return 0;
>
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator