Massivda ikki marta takrorlangan elementlarini ekranga chiqazing


Download 397.41 Kb.
Sana24.12.2022
Hajmi397.41 Kb.
#1060236
Bog'liq
aynomus59


O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
LABARATORIYA ISHI
Bajardi: *
Qabul qildi: *

Toshkent 2022

Massivda ikki marta takrorlangan elementlarini ekranga chiqazing.
#include
#include

using namespace std;

int main()
{
int n;

cout << "Son Kiriting = "; cin >> n;
cout << n << " gacha bo'lgan TUB sonlar :" << endl;

for (int i = 2; i <= n; i++)
{
bool tub = true;
for (int j = 2; j <= sqrt(i); j++)
{
if (i % j == 0)
{
tub = false;
break;
}
}
if (tub == true)
cout << i << endl;
}
return 0;

}



Bu yerda faqat masivning juft elementini chiqaruvchi dastur tuzdim
#include
#include
using namespace std;
int main()
{
int m, n, a[10][10];
cout << "Satrlar sonini kiriting \nm=";cin >> m;
cout << "Ustunlar sonini kiriting \nn=";cin >> n;
cout <<"Massiv elementlarini kiriting \n";

for(int satr = 0; satr < m ; satr++)


for(int ustun = 0; ustun < n; ustun++){
cout << "a[" << satr << "][" << ustun << "]="; cin >> a[satr][ustun];
}

for(int satr = 0; satr < m; satr++){


for(int ustun = 0; ustun < n; ustun++)
if(a[satr][ustun]%2==0){
cout << a[satr][ustun] << "\t"; cout<<"\n";
}
}
system ("pause");
return 0;
}

Matritsadagi har bir satrning eng kattasini toppish
#include
#include
using namespace std;
void matrix_print(int a[10][10], int m, int n)
{
// matritsani jadval shaklida chiqarish
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cout << a[i][j] << "\t";
}
cout << "\n";
}
}
int satr_max(int a[], int n)
{
// massivning eng katta elementini aniqlash
int max = a[0];
for (int i = 1; i < n; i++)
if (max < a[i]) max = a[i];
return max;
}
int main()
{
int m, n, a[10][10];
cout << "Satrlar sonini kiriting \nm="; cin >> m;
cout << "Ustunlar sonini kiriting \nn="; cin >> n;
cout <<"Massiv elementlarini kiriting \n";
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
cin >> a[i][j];
cout << "Kiritilgan matritsa\n";
//funksiyaga matritsa, satrlar va ustunlar soni jo'natiladi
matrix_print(a, m, n);
for (int i = 0; i < m; i++)
{
// funksiyaga i-satrning 0-elementi adresini
// va elementlar sonini jo'natamiz
cout << i << "-satrning eng kattasi=" <<
satr_max(&a[i][0], n);
cout << endl;
}
return 0;
system ("pause");
}

Download 397.41 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling