|
|
back to boardShow all messages Hide all messagesAC Dashka_Bu 10 Mar 2012 20:11 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 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 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 |
|
|