Topshiriq. 8-misol
Download 65.05 Kb.
|
1-labaratoriya
- Bu sahifa navigatsiya:
- Topshiriq. 19-misol
Topshiriq. 8-misol /* * Z(N) massiv berilgan. U massivni quyidagicha shakllantiring: * Z massivning oldin musbat keyin manfiy va nolga teng * elementlarini joylashtirish orqali. */ #include #include #include #include #include using namespace std; int main () { srand(time(0)); int N, s=0; cout<<" Massiv elementlari sonini kiriting -> "; cin>>N; int Z[N], U[N]; for(int i=0; i {
int SS=rand()%200-100; cout< }
for (int i = 0; i < N; i++) if (Z[i]>0) { U[s]=Z[i]; s++; } } for (int i = 0; i < N; i++) { if (Z[i]<0) { U[s]=Z[i]; s++; } } for (int i = 0; i < N; i++) { if (Z[i]==0) { U[s]=Z[i]; s++; } } cout< for(int i=0; i cout< }
} Topshiriq. 19-misol /* * N o'lchovli massiv berilgan. Lokal maksimumlar orasidan eng * minimalini toping. */ #include #include #include #include #include using namespace std; int main (){ srand(time(0)); int N, s=0, a, b; cout<<" Massiv elementlari sonini kiriting -> "; cin>>N; int X[N], U[N]; for(int i=0; i int SS=rand()%200-100; X[i]=SS;
cout< }
cout<<"\n\n"; cout<<" Maksimalning kichigini kiriting -> "; cin>>a; cout<<" Maksimalning kattasini kiriting -> "; cin>>b;
for (int i = 0; i < 20; i++) {
if (a<=X[i] && X[i]<=b) U[s]=X[i]; s++; } }
cout<<" Lokal maksimallar oralig'iga kiruvchi qiymatlar.\n"; for(int i=0; i cout< } cout< if (min>=U[i]) min=U[i]; cout<<" Minimal qiymati -> "< |
ma'muriyatiga murojaat qiling