|
Nxn matritsaning pastki chap uchburchagidagi elementlaridan vektor hosil qiling
|
tarix | 24.11.2022 | ölçüsü | 8,76 Kb. | | #70335 |
| amaliy ish 1
nxn matritsaning pastki chap uchburchagidagi elementlaridan vektor hosil qiling
4-variant
4 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ş: |
|
|