//t1.txt должен быть в папке с программой //Pascal var f: text; numValue, Counts, n, c, t, i: integer; begin assign(f, 't1.txt'); reset(f); Counts := 0; c := 0; while not eof(f) do begin readln(f, n); if (c = 0) or (n = t) then c := c + 1 else c := 1; t := n; if c > Counts then begin Counts := c; numValue := n end end; close(f); assign(f, 't2.txt'); rewrite(f); writeln('Длина цепочки: ', Counts); for i := 1 to Counts do writeln(f, numValue); close(f) end.
#include <iostream>
#include <ctime>
#include <iomanip>
using namespace std;
int main() {
int N, M, sum;
cout << "Vvedite N = "; cin >> N;
cout << "Vvedite M = "; cin >> M;
int **Arr = new int* [N];
for (int i = 0; i < N; i++)
Arr[i] = new int [M];
srand(time(0));
for (int i = 0; i < N; i++)
for (int j = 0; j < M; j++)
Arr[i][j] = rand() % 51;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
cout << setw(4) << setprecision(2) << Arr[i][j] << " ";
cout << endl;
}
cout << endl;
for (int j = 0; j < M; j++)
{
sum = 0;
for (int i = 0; i < N; i++)
sum = sum + Arr[i][j];
cout << setw(4) << setprecision(2) << sum << " ";
}
cout << endl;
system("pause");
return 0;
}
//t1.txt должен быть в папке с программой
//Pascal
var
f: text;
numValue, Counts, n, c, t, i: integer;
begin
assign(f, 't1.txt');
reset(f);
Counts := 0;
c := 0;
while not eof(f) do
begin
readln(f, n);
if (c = 0) or (n = t) then
c := c + 1
else
c := 1;
t := n;
if c > Counts then
begin
Counts := c;
numValue := n
end
end;
close(f);
assign(f, 't2.txt');
rewrite(f);
writeln('Длина цепочки: ', Counts);
for i := 1 to Counts do
writeln(f, numValue);
close(f)
end.