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

不明白了,这题在UVA上提交一点问题没有,为什么在这里就Runtime Error?

Posted by xiaomi at 2003-06-28 19:13:26 on Problem 1026
#include <iostream.h> 
#include <stdio.h> 
#include <string.h> 
int *a; 
int (*b)[201]; 
int *step; 
char *code; 
int i,j,k,m,n; 
int home,go; 
char msg[220]; 
int main() 
{ 
    cin>>n; 
    while (n!=0) 
    { 
        a=new int[n]; 
        b=new int[n][201]; 
        step=new int[n]; 
        code=new char[n]; 
        for (i=0;i<n;i++) 
            cin>>a[i]; 
        k=0; 
        for (i=0;i<n;i++) 
        { 
            home=go=b[i][0]=i-k; 
            step[i]=0; 
            do 
            {         
                go=a[go]-1; 
                step[i]++; 
                b[i][step[i]]=go; 
            } 
            while (go!=home); 
        } 
        scanf("%d",&m); 
        while (m!=0) 
        { 
            for (j=0;j<n;j++) 
                code[j]=32; 
            gets (msg);  
            for (i=1;i<int(strlen(msg));i++) 
                code[b[i-1][m%step[i-1]]]=msg[i]; 
            for (i=0;i<n;i++) 
                cout<<code[i]; 
            cout<<endl; 
            scanf("%d",&m); 
        } 
        cout<<endl; 
        delete[] a; 
        delete[] b; 
        delete[] step; 
        delete[] code; 
        cin>>n; 
    } 
    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