
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int a[5][5] =
{
{4,-5,8,-3,1},
{-3,8,-1,1,-8},
{9,6,6,-3,-7},
{-7,-3,3,6,-7},
{7,-3,-6,5,0},
};
int b[5][5];
int i, j, cp, cm, sp, sm;
setlocale(LC_ALL, "Russian");
cout << "Массив A";
for (i = 0; i < 5; i++) {
cout << endl;
for (j = 0; j < 5; j++) {
cout << setw (4) << a[i][j];
}
}
cp = cm = sp = sm = 0;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
if (a[i][j] >= -5)
b[i][j] = a[i][j];
else
b[i][j] = - a[i][j];
if (a[i][j] > 0) {
cp++;
sp += a[i][j];
}
if (a[i][j] < 0) {
cm++;
sm += a[i][j];
}
}
}
cout << endl << endl;
cout << "Среднее значение положительных элементов = " << (float) sp / cp << endl;
cout << "Среднее значение отрицательных элементов = " << (float) sm / cm << endl << endl;
cout << "Массив B";
for (i = 0; i < 5; i++) {
cout << endl;
for (j = 0; j < 5; j++) {
cout << setw(4) << b[i][j];
}
}
return 0;
}
Задача 1.
var n,a: integer;
begin
writeln('Введите 4-х значное число');
readln(n);
a := n mod 10;
n := n div 10;
write(a);
write(n)
end.
Задача 2.
var n: integer;
begin
writeln('Введите расстояние в сантиметрах: ');
readln(n);
writeln('Расстояние в метрах = ',n div 100)
end.
Задача 3.
var a,b,c: integer;
begin
writeln('Введите 1 число: ');
readln(a);
writeln('Введите 2 число: ');
readln(b);
c:=1;
if a > b then
begin
c := a*a*a*a;
end
else
begin
c:= b*b*b*b;
end;
writeln('Четвертая степень наибольшего числа = ',c);
end.
Задание 3.
1110111₂ = 1∙2⁶+1∙2⁵+1∙2⁴+0∙2³+1∙2²+1∙2¹+1∙2⁰ = 64+32+16+0+4+2+1 = 119₁₀
43₈ = 4∙8¹+3∙8⁰ = 32+3 = 35₁₀
119+35=154
Переводим в шестеричную:
154/6= 25 и остаток 4
25/6= 4 и остаток 1
154₁₀ = 414₆
ответ: 414₆
Задание 4.
26/2=13 и остаток 0
13/2=6 и остаток 1
6/2=3 и остаток 0
3/2 = 1 и остаток 1
26₁₀=11010₂
ответ: 11010₂
Задание 5.
163₇= 1∙7²+6∙7¹+3∙7⁰ = 49+42+3 = 94₁₀
ответ: 94₁₀
Объяснение: