Ответ:
Объяснение:
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand((int)time(0));
int n, m=0;
cout <<"Enter n: "; cin >>n;
int **a = new int*[n];
for (int i = 0; i < n; i++)
a[i]=new int[n];
int*B = new int[n];
int k=0;
for (int j = 0; j < n; j++)
a[i][j]=rand()%19-9;
cout <<a[i][j]<<" ";
if (a[i][j]>0 && k==0) {B[m++]=a[i][j]; k++;}
}
if (k==0) B[m++]=1;
cout <<endl;
cout <<B[i]<<" ";
delete [] a[i];
delete [] a;
delete [] B;
system("pause");
return 0;
1
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
Объяснение:
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand((int)time(0));
int n, m=0;
cout <<"Enter n: "; cin >>n;
int **a = new int*[n];
for (int i = 0; i < n; i++)
a[i]=new int[n];
int*B = new int[n];
for (int i = 0; i < n; i++)
{
int k=0;
for (int j = 0; j < n; j++)
{
a[i][j]=rand()%19-9;
cout <<a[i][j]<<" ";
if (a[i][j]>0 && k==0) {B[m++]=a[i][j]; k++;}
}
if (k==0) B[m++]=1;
cout <<endl;
}
cout <<endl;
for (int i = 0; i < n; i++)
cout <<B[i]<<" ";
cout <<endl;
for (int i = 0; i < n; i++)
delete [] a[i];
delete [] a;
delete [] B;
system("pause");
return 0;
}
1