We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I'm having the same trouble. I've tested this locally and it works, and I've passed test case #0 and #1, but mysteriously, not #2 (apologies for the Pascal, I'm a Delphi developer and it's my most comfortable language):
(* Enter your code here. Read input from STDIN. Print output to STDOUT *)programArraySum;vararraySize,i,sum,valErr:integer;intArray:arrayofinteger;inputIntString,subIntString:string;beginreadln(arraySize);SetLength(intArray,arraySize);readln(inputIntString);i:=0;while(i<arraySize)and(inputIntString<>'')dobeginsubIntString:=Copy(inputIntString,0,Pos(' ',inputIntString)-1);ifsubIntString=''thenbeginsubIntString:=inputIntString;end;Val(subIntString,intArray[i],valErr);inputIntString:=Copy(inputIntString,Pos(' ',inputIntString)+1,Length(inputIntString));i:=i+1;end;i:=0;sum:=0;while(i<arraySize)dobeginsum:=sum+intArray[i];i:=i+1;end;writeln(sum);end.
Simple Array Sum
You are viewing a single comment's thread. Return to all comments →
I'm having the same trouble. I've tested this locally and it works, and I've passed test case #0 and #1, but mysteriously, not #2 (apologies for the Pascal, I'm a Delphi developer and it's my most comfortable language):