fork download
  1. program ideone;
  2. var
  3. myArray : array of Integer;
  4. currentIndex : Integer;
  5.  
  6. begin
  7. // Initialize the dynamic array (e.g., with a starting size)
  8. SetLength(myArray, 1);
  9.  
  10. // Add elements (example)
  11. myArray[0] := 1;
  12. currentIndex := 0;
  13.  
  14. // Add a new element
  15. SetLength(myArray, currentIndex + 2);
  16. myArray[currentIndex + 1] := 2;
  17. currentIndex := currentIndex + 1;
  18. writeln(myArray[currentIndex ])
  19. end.
  20.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
2