1. str.txt. . .
Program MyTest10_1;
{$APPTYPE CONSOLE}
Uses SysUtils, EsConsole in EsConsole.pas;
Var F: TextFile;
Str1: String[80];
Begin
AssignFile (f,str.txt);
Reset (f);
{--- ---}
While not eof (f) do
Begin
readln(f,str);
writeln(str);
end;
CloseFile(f);
end.
2. input.txt, . . . , . . : . output.txt, . .
:
:
program ex2;
{$APPTYPE CONSOLE}
Uses SysUtils, EsConsole in EsConsole.pas;
var f1,f2: textFile;
n,k,i,sumk: integer;
sred:real;
a: array [1..100] of integer;
Begin
assignFile(f1,'input.txt'); reset(f1);{ }
{ }
readln(f1,n);readln(f1,k);
for i:=1 to n do read(f1,a[i]); { }
closeFile(f1);{ , }
assignFile(f2,'output.txt');rewrite(f2); { }
{ }
writeln(f2);writeln(f2);writeln(f2,'ischod massiv');
{ }
for i:=1 to n do write(f2,a[i],' ');writeln(f2);
{ k- }
sumk:=0;
for i:=1 to k do sumk:=sumk+a[i];
{ , }
writeln(f2);writeln(f2);writeln(f2,'sum do ',k,'-o elem=',sumk);
{ k- }
sred:=0;
for i:=k+1 to n do sred:=sred+a[i];
sred:=sred/(n-k);
{ , }
writeln(f2);writeln(f2);writeln(f2,'sred ot ',k,'-o elem=',sred:10:3);
closeFile(f2);
end.
3. c dat.dat, . . , .
, , .
:
:
program ex_file;
{$APPTYPE CONSOLE}
Uses SysUtils, EsConsole in EsConsole.pas;
var f:textFile;
n,m,i,j,max,iMax,jMax: integer;
matr: array [1..100,1..100] of integer;
Begin
assignFile(f,'input3.txt');reset(f);
|
|
readln(f,n,m);
for i:=1 to n do for j:=1 to m do read(f,matr[i,j]);closeFile(f);
assignFile(f,'output3.txt');rewrite(f);
writeln(f,'matr1');
for i:=1 to n do begin
for j:=1 to m do write(f,matr[i,j],' ');
writeln(f);
end;
max:=matr[1,1]; iMax:=i;jMax:=j;
for i:=1 to n do for j:=1 to m do
if max<matr[i,j] then begin max:=matr[i,j];iMax:=i;jMax:=j end;
writeln(f);writeln(f,'max=',max);
writeln(f,'index''s ',iMax,' ',jMax);
closeFile(f);
end.
1. ?
2. ?
3. ?
1. :
1) File
2) Filetext
3) Textfile
4) Of
5) < >
6) string
2. :
1) Var t: textfile;
2) Var t: file of string;
3) Var t: filetext;
4) Var t: text of file;
3. :
1) For-to-do
2) For-downto-do
3) While-do
4) Repeat-until
1: ()
.
input1.txt, . , , v . output1.txt :
< >
< 1 >
- =< >
< 2 >
v=< v>
.
2: ()
.
input2.txt, . . output2.txt , .
.
1 . 1. . . 2. , . , .
2 . 1. , . . 2. , , , , .
3 . 1. , , . . 2. , , , .
4 . 1. . . 2. . .
5 . 1. , . , . 2 . 2. .
|
|
6 . 1. , . 3 . 2. , , , .
7 . 1. . 3 . 2. , . , , .
8 . 1. , , . 4 . 2. .
9 . 1. . 2. , , . , .
10 . 1. . 2. , ; . , .
11 . . , , .
12 . . .
3: , ()
.
, input3.txt. output3.txt.
1. . .
2. :
massiv:
< >
< >
<5 >itog=< >
4: ,
, .
.
1. . , .
2. , , , .
3. .
1 . . 2 . .
2 . . 4 . , 4- . , .
3 . . 1 . 3- 7 . , .
4 . . 3 . , . , .
5 . . 2 . , . , .
|
|
6 . . 5 . .
7 . . 4 . 5. , .
8 . . 2 . , 3- 8- . , .
9 . . 3 . . 2 . , . , .
10 . . 1 . . 1 . , 3. , .
11 . . 6 . .
12 . . 2 . 9. , .
5: , ()
.
1. , , . . , .
2. , .
1. : , ; , , , , ( ) (. 3).
2. , . .
6: ,
.
1. .
2. .
1. .
2. , , .
1 . N . N-1 , .
2 . : , .
|
|
3 . N x M, k, t (1£ k £N, 1£ t £N, k ¹ t). , k t, .
4 . N x M (N < M) M. : , .
5 . N. : d s, .
6 . , .
7 . N N. . , , , , .
8 . N N. , , .
9 . N. , .
10 . N . N-1 , .
11 . N N. , , .
12 . : , .