ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1581. Teamwork

AC
Posted by Dashka_Bu 10 Mar 2012 20:11
program idiots;
var n,i,h:integer;
a: array [1..1000] of integer;
begin
for i:=1 to n do
h:=1;
for i:=1 to n do
begin
if a[i]=a[i+1] then h:=h+1;
if a[i]<> a[i+1] then write(h,' ',a[i],' ');
if a[i]<> a[i+1] then h:=1;
end;
end.
Re: AC
Posted by kami_botanik 14 Mar 2013 20:05
but, I don't understood!
for i:=1 to n do
begin
if a[i]=a[i+1] then h:=h+1;
if a[i]<> a[i+1] then write(h,' ',a[i],' ');
if a[i]<> a[i+1] then h:=1;
end;
You must get error in this stroke if a[i]=a[i+1] then h:=h+1; because your for loop is going untill n this must give Indexout of range exception isn't?
Re: AC
Posted by SeaEagle 30 Dec 2017 16:27
Nope, its neither c++ nor Java. It`s Pascal. Here you can do a lot of forbidden things without getting runtime error or Exception