|  | 
|  | 
| back to board | AC program idiots;var n,i,h:integer;
 a: array [1..1000] of integer;
 begin
 readln(n);
 for i:=1 to n do
 read(a[i]);
 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 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 Nope, its neither c++ nor Java. It`s Pascal. Here you can do a lot of forbidden things without getting runtime error or Exception | 
 | 
|