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?以下是source code #include <iostream.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define STR_LENGTH 500000 #define DATA_LENGTH 100 _int64 Get_Measure(int* Seqs,int head,int tail); int main() { int Seqs[STR_LENGTH]; //Get the Seqs int number; int counter; _int64 result; cin>>number; while (number!=0) { for(counter=0;counter<number;counter++) { cin>>Seqs[counter]; } result=Get_Measure(Seqs,0,number-1); scanf("%I64\n",&result); cin>>number; } return 0; } _int64 Get_Measure(int* Seqs,int head,int tail) { if (head==tail) return 0; _int64 sum=0; int length; int* array; array=(int*)malloc(sizeof(int)*(tail-head+1)); sum=Get_Measure(Seqs,head,(head+tail)/2)+Get_Measure(Seqs,(head+tail)/2+1,tail); length=(head+tail)/2-head+1; int i,tag1=head,tag2=(head+tail)/2+1; for(i=0;i<tail-head+1;i++) { if (Seqs[tag1]<Seqs[tag2]) { array[i]=Seqs[tag1]; tag1++; length--; } else { array[i]=Seqs[tag2]; tag2++; sum+=length; } } for(i=0;i<tail-head+1;i++) Seqs[head+i]=array[i]; free(array); return sum; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator