Muhammad al-xozmiy nomidagi toshkent axborot texnologialar universiteti




Download 296,39 Kb.
Sana16.05.2024
Hajmi296,39 Kb.
#239091
Bog'liq
dastur3


MUHAMMAD AL-XOZMIY NOMIDAGI TOSHKENT AXBOROT
TEXNOLOGIALAR UNIVERSITETI


DASTURLASH

15 variant

Topshiriqqa muvofiq massiv va matrixga doir bo’lgan masalalarni PARAMETRLI FUNKSIYA hosil qilib yechish lozim.


1-jadval.(MASSIV)

#include
#include
using namespace std;
void createReversedArray(const vector& x, vector& y) {
y.clear();
for (int i = x.size() - 1; i >= 0; i--) {
y.push_back(x[i]);
}
}
int calculateProductOfEvenIndexed(const vector& y) {
int product = 1;
for (int i = 0; i < y.size(); i += 2) {
product *= y[i];
}
return product;
}
int main() {
vector x = {1, 2, 3, 4, 5};
vector y;
createReversedArray(x, y);
cout << "Y massivi: ";
for (int i = 0; i < y.size(); i++) {
cout << y[i] << " ";
}
cout << endl;
int result = calculateProductOfEvenIndexed(y);
cout << "Juft indeksli elementlarining ko'paytmasi: " << result << endl;
return 0; }

2- jadval. (MATRIX)


#include


using namespace std;
int main() {
char A[9][9] = {
{' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', '*', '*', '*', ' ', ' ', ' '},
{' ', ' ', '*', '*', '*', '*', '*', ' ', ' '},
{' ', '*', '*', '*', '*', '*', '*', '*', ' '},
{'*', '*', '*', '*', '*', '*', '*', '*', '*'},
{' ', '*', '*', '*', '*', '*', '*', '*', ' '},
{' ', ' ', '*', '*', '*', '*', '*', ' ', ' '},
{' ', ' ', ' ', '*', '*', '*', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' '}
};

float s = 0;


for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (A[i][j] == '*') {
s += 1;
}
}
}

cout << "Matritsadagi bo'yalgan sohalardagi elementlar yig'indisi: " << s << endl;


return 0;


}

Download 296,39 Kb.




Download 296,39 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa



Muhammad al-xozmiy nomidagi toshkent axborot texnologialar universiteti

Download 296,39 Kb.