#include <cctype> #include <algorithm> #include <cmath>#include <iomanip> #include <windows.h>#include <conio.h>#include <set>#include <iostream> #include <string> #include <vector> using namespace std; int main(){ int a, b,f=0,f1=0,ans=0; cin >> a >> b; if (a < 0 ) f = 1; if (b < 0) f1 = 1; for (int i = 0; i < abs(b);i++) { ans += a; } if (f == 1 && f1 == 1) cout << abs(ans); else if (f == 1 || f1 == 1) cout << '-' << abs(ans); else cout << ans; 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.
int main(){ int a, b,f=0,f1=0,ans=0; cin >> a >> b; if (a < 0 ) f = 1; if (b < 0) f1 = 1; for (int i = 0; i < abs(b);i++) { ans += a; } if (f == 1 && f1 == 1) cout << abs(ans); else if (f == 1 || f1 == 1) cout << '-' << abs(ans); else cout << ans; 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.