How to make, after entering the data into the matrix, the program asks whether everything was correctly entered and if not, then offered to select which line exactly and made it possible to correct this error in it?

I assumed that you could use: function TryStrToFloat(s: string; var value: single): boolean; However, I really don’t know how to work with it and something isn’t working out yet. Can you please tell me any other ways, or how to work with this function?

Here is a part of the code in which you actually need to “plug in” this code (I apologize for the tautology):

 writeln('Решение СЛАУ по методу Гаусса.'); repeat writeln; writeln('Введите колич-во неизвестных величин и нажмите ENTER:'); readln(s);{читаем строку} val(s,x,v);{пытаемся преобразовать ее в число, в переменную C - упадет позиция, с недопустимым символом} if v<>0 then writeln('Должно быть число') else n := Round(x); until v=0; 
  • I made it so that I asked and returned, but used goto to go to the beginning of the cycle, but I would like it so that the user could choose which value he would like to go to, fix it, and so that the program would continue - Sergey M

1 answer 1

Break your question into subtasks.

Each subtask is performed by a separate small procedure or function.

As an example, partly in pseudocode:

 function EnterNumber: Double; var s: string; begin repeat readln(s); if not TryStrToFloat(s, Result) then writeln('Требуется число') else Break; until False; end; procedure EnterMatrixElement(Row, Col: integer); begin Matrix[Row, Col]:=EnterNumber; end; function IsAllOk: Boolean; begin // спрашиваем - все ли в порядке Result:= что_ответил_пользователь (да/нет) end; {узнавание_размерности_матрицы;} {исходное_заполнение_матрицы} while not IsAllOk do // пока пользователь не скажет, что всё в порядке begin Write('В какой строке неправильно?'); // узнаем координаты ошибочного ввода Row:=Round(EnterNumber); Write('В каком столбце?'); Col:=Round(EnterNumber); EnterMatrixElement(Row, Col); // и меняем его содержимое. end; // сюда попадем только когда пользователь скажет, что "да, всё ок". 
  • something is not working out. Than to replace EnterMatrixElement, otherwise he says that the name is unknown, although as the procedure is announced, it is the same with "Matrix" and with "EnterNumber", the first I tried to replace with the variable "a", It is my responsibility for the dimension of the array and is defined by the type "real", but it does not help - Sergey M
  • @SergeyM I think you have a problem with the wrong syntax. With normal spelling (do not forget that this is not all application code, but only a part - with reference to the question) - everything compiles without problems. Actually, your question is answered by the last part of the code (namely, the while loop) given by me in the answer. I wrote everything else solely for the purpose of explaining what exactly the different parts of the program should do. - kami
  • and why after inserting this function and procedure (function EnterNumber: Double;) (procedure EnterMatrixElement (Row, Col: integer);), I have the output error that at the end of the program it was not "end." that was expected but "end;" or they do not need to insert? But otherwise, he says to me that these names are again unknown. And it is useless to replace them with other names, anyway, he writes the same thing - Sergey M
  • @SergeyM because you need to improve the syntax of the language you are using. In particular, the main body of the program begins with begin and ends with end. And since the answer voiced the concept , these reserved words, as well as variable declarations in the code I have given, are not. - kami