Topshiriq. 8-misol


Download 65.05 Kb.
Sana15.10.2020
Hajmi65.05 Kb.
#133877
Bog'liq
1-labaratoriya




  1. 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;



Z[i]=SS;

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<

cout<<" U massiv elementlari :) \n";

for(int i=0; i

cout<

}

getch();



}



  1. 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<<" Maksimallar oralig'ini kiriting:\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<

int min=U[0];

cout<<" Lokal maksimallar oralig'iga kiruvchi qiymatlar.\n";

for(int i=0; i

cout<

}

cout<

for(int i=1; i

if (min>=U[i]) min=U[i];



}

cout<<" Minimal qiymati -> "<

getch();

}



  1. Topshiriq. 8-misol


/*

* O'nlik butun son ko'rinishdagi satr berilgan.

* Ikkilik ko'rinishdagi satr shakllantirilsin va ekranga chiqarilsin.

*/

#include "stdafx.h"

#include

#include

using namespace System;

using namespace std;

int main(){

string str;

cout<<"Satrli sonni kiriting: ";

getline(cin,str);

int number10 =stoi(str);

int number=1;

int number2=0;

while (number10>0)

{

number2+=((number10)%2)*number;

number10=number10/2;

number*=10;

}

Console::WriteLine(L" Bu sonning 2 lik SS : ");

cout<<number2;

Console::ReadKey();

return 0;

}


Download 65.05 Kb.

Do'stlaringiz bilan baham:




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