fork download
  1. program kivalasztas_utolso;
  2. const n = 10;
  3. var a:array [1..n] of integer;
  4. i, sorsz: integer;
  5. begin
  6. randomize;
  7. //a tömb elkészítése
  8. for i:=1 to n do
  9. begin
  10. a[i]:=random(8);
  11. write(a[i], ' ');
  12. end;
  13. writeln;
  14. //mi az utolsó 5-ös sorszáma?
  15. for i:=1 to n do
  16. if a[i]=5 then
  17. sorsz:= i;
  18. write('Az utolso 5-os elem sorszama: ', sorsz);
  19. readln;
  20. end.
Success #stdin #stdout 0s 9120KB
stdin
Standard input is empty
stdout
1 1 0 3 5 5 1 4 5 2 
Az utolso 5-os elem sorszama: 9