Попробуй, коли что не пойдет - напишешь.
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| #include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int i, n, j, s, k;
int nmax;
s=20;
nmax = ((s*(s+1))/2);
int mas[nmax];
int mas2[nmax][nmax];
// âîçìîæГ*Г* ÔóГ*ГЄГ¶ГЁГї ïîâòîðГ*
cout << "ГђГ*çìåð Г¬Г*òðèöû äî "<<nmax<<"n= ";
cin>>n;
cout <<"\n";
//
cout <<"ÝëåìåГ*ГІГ» âåðõГ*ГҐГ© òðåóãîëüГ*îé Г¬Г*òðèöû ";
j= ((n*(n+1))/2);
for (i=1; i<=j; i++)
{
mas[i] = (rand() % 50+1);
cout<<mas[i]<<" ";
}
cout<<"\n";
cout<<"\n";
cout<<"ÈñõîäГ*Г*Гї Г¬Г*òðèöГ* ";
k=0;
for (i=0;i<=n;i++)
{
for(j=i;j<=n;j++)
{
k=k+1;
mas2[i][j]=mas[k];
mas2[j][i]=mas[k];
}
}
for(i=0;i<=n;i++)
{
for(j=i;j<=n;j++)
{
cout<<mas2[i][j]<<" ";
}
cout<<"\n";
}
getch();
return 0;
} |
|