#include <iostream>
#include <vector>
using namespace std;
float summatrix(vector < vector<float>>& v) {
float s=0;
for (int i = 0; i < v.size(); i++) {
for (int j = 0; j < v[i].size(); j++) {
if (j > i) s += v[i][j];
}
}
return s;
}
float mulmatrix(vector < vector<float>>& v) {
float s = 1;
for (int i = 0; i < v.size(); i++) {
for (int j = 0; j < v[i].size(); j++) {
if (i > j) s *= v[i][j];
}
}
return s;
}
int main()
{
//создадим матрицу 5 на 5 и заполним ее случайными числами
vector < vector<float>> v1(5,vector<float>(5));
for (auto& it1 : v1) {
for (auto& it2 : it1) {
it2 = float(rand()%100+1)/10.0;
}
}
//создадим матрицу 8 на 8 и заполним ее случайными числами
vector < vector<float>> v2(8, vector<float>(8));
for (auto& it1 : v2) {
for (auto& it2 : it1) {
it2 = float(rand()%100+1) / 10.0;
}
}
//Выведем матрицы на экран
for (auto& it1 : v1) {
for (auto& it2 : it1) {
cout << it2 << " ";
}
cout << endl;
}
cout << endl;
for (auto& it1 : v2) {
for (auto& it2 : it1) {
cout << it2 << " ";
}
cout << endl;
}
cout << endl;
cout << "sum v1=" << summatrix(v1)<<endl;
cout << "sum v2=" << summatrix(v2) << endl;
cout << "mul v1=" << mulmatrix(v1) << endl;
cout << "mul v2=" << mulmatrix(v2) << endl;
}
Объяснение:
Объяснение:
1.
A=int(input('А='))
B=int(input('B='))
i=A
while i>=B:
print(i, end=" ")
i-=1
2.
for i in range(101,322):
if i%4==0 and i%6>0:
print(i)
3.
n=int(input('N='))
s=[]
for i in range(n):
k=input('Введите число =')
s.append(int(k[::-1]))
for i in (s[:-1]):
print(i,end=', ')
print(s[-1],end=".")