|
Nxn matritsaning pastki chap uchburchagidagi elementlaridan vektor hosil qiling
|
tarix | 23.11.2022 | ölçüsü | 34,55 Kb. | | #70018 |
| Nxn matritsaning pastki chap uchburchagidagi elementlaridan vekt
5-variant
nxn matritsaning pastki chap uchburchagidagi elementlaridan vektor hosil qiling
#include
#include
using namespace std;
int main()
{
srand(time_t(NULL));
vector vektor;
int matritsa[100][100]; int n;
cout << "Kvadrat matritsaning tartibi kiriting = "; cin >> n;
for (int i = 0; i < n; i ++)
{ for (int j = 0; j < n; j ++)
/*matritsani tasodifiy qiymatlar bilan toldirish*/
{
int random = rand() % 100 + 1;
matritsa[i][j] = random;
}
}
for (int i = 0; i < n; i ++)
{ for (int j = 0; j < n; j ++)
/*matritsa korinishida chiqarish*/
cout << matritsa[i][j]<< " ";
cout << endl;
}
cout << endl;
for (int i = 0; i < n; i ++)
{ for (int j = 0; j < n; j ++)
if(i >= j)
{ /*vectorga matritsaning pastki chap uchburchagidagi elementlarni o’zlashtirish*/
vektor.push_back(matritsa[i][j]);
}
}
cout << "Vector elementlari" << endl;
for(int i = 0; i < vektor.size(); i ++)
{
cout << vektor[i] << " ";
}
return 0; }
Dostları ilə paylaş: |
|
|