#include< iostream> using namespace std; int main() { int n,a,b,counta_a=0, count_b=0; cout < < "введите сначала число n, затем число а, затем число b \n"; cin > > n > > a > > b; while (n! =0): switch (n) { case a: count_a++; break; case b: count_b++; break; } if (count_a > = count_b) cout < < "число "+ a + "встречается чаще, чем "+ b; else cout < < "число "+ a + "реже чаще, чем "+ b; }
rstas
13.02.2021
Var a: array[1..3,1..3] of integer; t: array[0..2] of boolean; k: array[0..2] of integer; i,j: integer; res: boolean; begin for i : = 1 to 3 do for j : = 1 to 3 do read(a[i,j]); for i : = 0 to 2 do begin k[i] : = 0; t[i] : = false; end; for i : = 1 to 3 do for j : = 1 to 3 do k[a[i,j]] : = k[a[i,j]] + 1; for i : = 1 to 3 do begin if (a[i,1] = a[i,2]) and (a[i,2] = a[i,3]) then t[a[i,1]] : = true; if (a[1,i] = a[2,i]) and (a[2,i] = a[3,i]) then t[a[1,i]] : = true; end; if (a[1,1] = a[2,2]) and (a[2,2] = a[3,3]) then t[a[2,2]] : = true; if (a[3,1] = a[2,2]) and (a[2,2] = a[1,3]) then t[a[2,2]] : = true; res : = true; if (k[1] - k[2] > 1) or (k[1] - k[2] < 0) then res : = false; if t[1] and ( t[2] or (k[1] = k[2]) ) then res : = false; if res then writeln('yes') else writeln('no') end.
Бондарен1076
13.02.2021
Var a: array[1..100] of integer; i,n,c,h: integer; begin writeln('введите кол-во элементов последовательности: '); readln(n); writeln('введите последовательность: '); for i: =1 to n do begin read(a[i]); if a[i]< 0 then begin c: =c+a[i]; h: =h+1; end; end; writeln(c/h); end.