TransWikia.com

Ошибка времени выполнения: Индекс находился вне границ массива. PascalABC.net

Stack Overflow на русском Asked by pascalnewbie1112 on January 8, 2021

var
  A: array [1..300] of integer; 
  n, i, ob: integer; 
  f: boolean;

procedure pov(var b: integer);
var
  st: string; 
  j, k, code: integer;
begin
  str(b, st); 
  k := 0; 
  for j := 1 to length(st) - 1 do
  begin
    inc(k);
    if st[j] = st[j + k] then
      delete(st, j + k, 1);
  end;
  val(st, b, code); 
  write(b);
end;

begin
  read(n); 
  for i := 1 to n do 
    read(A[i]);
  for i := 1 to n do 
    pov(A[i]); 
  repeat
    f := true; 
    for i := 1 to n do
      if A[i] > A[i + 1] then
      begin
        ob := A[i]; 
        A[i] := A[i + 1]; 
        A[i + 1] := ob; 
        f := false;
      end;
  until f; 
  for i := 1 to n do
    writeln(A[i]);
end.

One Answer

Бог ты мой, разве так на PascalABC.NET пишут? Вот все решение и пример, если я условие Ваше правильно понял:

begin
  var n := ReadInteger;
  var a := ReadArrInteger(n);
  var b := a.Select(t -> t.ToString.Distinct.JoinToString.ToInteger).Order.ToArray;
  b.Print
end.

3
123423 11111 345632
1 1234 34562

Answered by RAlex on January 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP