The task is to write the number in reverse order (for example, 69 => 96).

procedure TForm1.Button1Click(Sender: TObject); var Perevorot: array [1..100] of integer; MyIndex, MySum: integer; begin MySum := StrToInt(Edit1.Text); // На входе 69 for MyIndex := 10 to 1 do MySum := MySum - Perevorot[MyIndex]; Edit2.Text := IntToStr(MySum); // <<-- Тут должно быть 96 end; 

I get the result is still 69. Tell me, what is the error?

  • @Kromster, and what else can you improve? :-) - Grundy
  • @Kromster, well, the picture of the type shows that it does not turn over. You can rule will not break more :-) - Grundy

2 answers 2

Isn't it easier to convert to a number and then rewrite the line in the reverse order (find the length and, starting from the end, write to a variable in a loop)?

    I could not understand the logic of the program, but I see that the cycle operator is incorrectly specified. It is necessary downto instead of to. Now the for loop does not work.

    • @Get thanks, the loop really didn't work. But I still did not get the expected result. I will redo the program. - Igor_bogun
    • You have already been advised to use a string writeback, a standard Delphi procedure, or an integer division by 10. Are you trying to invent a bicycle? - Get
    • If you need to do it through an array, you can write each digit of a number into an array, and then output all the elements of the array in reverse order. - Get