Skip to content

Instantly share code, notes, and snippets.

@Poplava
Created October 30, 2014 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Poplava/aec642284dc5b91029e5 to your computer and use it in GitHub Desktop.
Save Poplava/aec642284dc5b91029e5 to your computer and use it in GitHub Desktop.
Education
#include <iostream>
using namespace std;
int b_max(int b1[]) //Èùåì íàéáîëüøèé ýëåìåíò âåêòîðà
{
int max1;
max1 = b1[0];
for (int i = 1; i < 5; i++)
{
if (b1[i] > b1[i - 1])
max1 = b1[i];
}
return max1;
}
int** a_pr(int a2[][4], int max2)
{
int** apr2 = new int*[4];
for (int i = 0; i < 4; i++) //temp
{
apr[i] = new int[4];
for (int j = 0; j < 4; j++)
{
apr2[i][j] = a2[i][j] * max2;
}
}
return apr2;
delete apr2;
}
int main()
{
int b[5], a[4][4], max;
char any_key;
int** apr = new int*[4];
cout << "\nHello! Input array 'b'\n";
for (int i = 0; i < 5; i++) //ââîä âåêòîðà
{
cout << "\n'b[" << i << "]'=";
cin >> b[i];
}
cout << "\nInput matrix 'a'\n\n";
for (int i = 0; i < 4; i++) //ââîä ìàòðèöû
{
for (int j = 0; j < 4; j++)
{
cout << "'a[" << i << "][" << j << "]'=";
cin >> a[i][j];
}
cout << endl;
}
for (int i = 0; i < 5; i++) //temp
{
cout << "\n'b[" << i << "]'=" << b[i];
}
cout << "\n\n";
for (int i = 0; i < 4; i++) //temp
{
for (int j = 0; j < 4; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
max = b_max(b); //Èùåì max
cout << "'max'=" << max;
apr = a_pr(a, max); //ïîëó÷àåì ïðîèçâåäåíèå
for (int i = 0; i < 4; i++) //âûâîä ìàòðèöû
{
for (int j = 0; j < 4; j++)
{
cout << apr[i][j] << " ";
}
cout << endl;
}
cin >> any_key; //temp
delete apr;
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment