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

请问,下面代码为什么会Runtime Error ?

Posted by mmx21 at 2010-12-27 14:17:31 on Problem 1159
#include "stdio.h"
        char str[5002];
	int length;
	short f[5002][5002];
	
	void dp() {
		int i,j;
		for(i = length - 2; i >= 0; i--) {
			for(j = i + 1; j < length; j++) {
				if(str[i] == str[j]){
					f[i][j] = f[i+1][j-1];
				} else {
					if(f[i+1][j] < f[i][j-1])
						f[i][j] = f[i+1][j] + 1;
					else
						f[i][j] = f[i][j-1] + 1;
				}
			}
		}
	}
	
	int main() {
		scanf("%d",&length);
		scanf("%s",str);
		dp();
		printf(f[0][length-1]);
                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