How to make the data entered not from the keyboard, but from the .txt file?

Program pf; var x,y,a,b:integer; begin read(x); read(y); a:=x; b:=y; if x>y then begin x:=a*b; y:=a+b; end else begin x:=a+b; y:=a*b; end; write(x,y); end. 
  • one
    In fact, you can read text from any file, up to the .shlasashaposhosse extension. - Mr. Don't know

1 answer 1

First add the code (after begin)

 assign(input, 'input.txt'); reset(input); assign(output, 'output.txt'); rewrite(output); 

It is not difficult to guess that input.txt and output.txt is the name of the input and output files, respectively.

  • @Alexander Zasovin Same thing, just add the code that I wrote to you after begin. Only you have no input there))) - Mr. Don't know