*80. Bir hafta davomidagi kundalik temperatura berilgan bo’lsa



Download 62,12 Kb.
Sana20.07.2022
Hajmi62,12 Kb.
#825527
Bog'liq
Dasturlash


Dasturlash

76
77


78
79
80
/*80. Bir hafta davomidagi kundalik temperatura berilgan bo’lsa,
hafta uchun o’rtacha temperaturani hisoblash dasturini
massivdan foydalanib tuzing.*/
#include
using namespace std;
int main(){
float c=0;
//Hafta bo'lgani uchun massiv soni 7ta bo'ladi.
for(int i=0; i<7; i++){
cin>>a[i];
}
for(int i=0; i c += a[i];
}
cout<}

81
82


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
100. Navbat o‘rtasiga '+' belgi joylashtirilsin.
#include
#include
using namespace std;
queue Qidirish(queue navbat) {
int a = navbat.size() / 2, n = 0;
queue yangi;
while (!navbat.empty()) {
n ++;
cout << navbat.front() << " ";
yangi.push(navbat.front());
if (n == a) {
yangi.push("+");
}
navbat.pop();
}
return yangi;
}
void Chiqarish(queue navbat) {
while (!navbat.empty()) {
cout << navbat.front() << " ";
navbat.pop();
}
}
int main() {
queue navbat;
cout << "";
navbat.push("1");
navbat.push("2");
navbat.push("3");
navbat.push("4");
navbat.push("5");
navbat.push("6");
navbat.push("7");
navbat.push("8");
navbat.push("9");
navbat.push("10");
navbat.push("11");
navbat.push("12");

cout << "Oldin: ";


navbat = Qidirish(navbat);
cout << "\nKeyin: ";
Chiqarish (navbat);
}
101
102

  1. Stek eng kichik elementi topilsin va uning o‘rniga 0 joylashtirilsin.

#include
#include
using namespace std;
int main() {
stack st, nw;
int n,min=0;
cout<<"N = ";
cin>>n;
for(int i=0; i int temp;
cin>>temp;
if(i == 0 || temp < min) min = temp;
st.push(temp);
}
while(!st.empty()) {
if( (st.top() == min) )
nw.push(0);
nw.push(st.top());
st.pop();
}
while(!nw.empty()) {
cout< nw.pop();
}
return 0;
}
103
104
105
105. Stek eng kichik elementi topilsin va undan keyin 0 joylashtirilsin.
#include
#include
using namespace std;
int main() {
stack st, nw;
int n,min=0;
cout<<"N = ";
cin>>n;
for(int i=0; i int temp;
cin>>temp;
if(i == 0 || temp < min) min = temp;
st.push(temp);
}
while(!st.empty()) {
if( (st.top() == min) )
nw.push(0);
nw.push(st.top());
st.pop();
}
while(!nw.empty()) {
cout< nw.pop();
}
return 0;
}

106
106. Navbat eng kichik elementi o‘chirilsin.


#include
#include
using namespace std;
int main()
{
queue qu;
queue qu2;
int n;
cout<<"Navbat elementlari sonini kiriting:";
cin >> n;
cout<<"Navbat elementlarini kiriting:";
for(int i=0, a; i{
cin >> a;
qu.push(a);
qu2.push(a);
}
const int& k = qu2.front();
int min = k;
for(int i=0; i{
if(qu2.front() < min) min = qu2.front();
qu2.pop();
}
cout << "min=" << min << endl;
for(int i=0; i{
if(qu.front() == min)
{
qu.pop();
continue;
}
qu2.push(qu.front());
qu.pop();
}
n = qu2.size();
for(int i=0; i{
cout << qu2.front() << " "; qu2.pop();
}
}
107
107 Navbatda birinchi elementga teng barcha elementlar o‘chirilsin.
#include
#include
using namespace std;
int main(){
queue q;
int a,index;
cout<<"Navbat elementlarini kirit:";
for (int i = 0; i < 10; i++) {
cin >> a;
q.push(a);
}
cin >> index;
for (int i = 0; i < q.size(); i++){
if (i == index) q.pop();
q.push(q.front());
q.pop();
}
cout << endl << endl<<"Natija:";
for (int i = 0; i < q.size(); i++){
cout << q.front() << ' ';
q.push(q.front());
q.pop();
}
return 0;
}
108

  1. Dekni o‘rtasiga “dek” so‘zini kiriting.

#include
#include
using namespace std;
int main() {
int i,n;
string tmp;
deque s; deque :: iterator it;
cout<<"Nechta so`z kiritmoqchisiz? :"; cin>>n;
cout<cin>>tmp; s.push_back(tmp);
}
if(n%2==0) {
n/=2; s.insert(s.begin()+n,"dek");
} else {
n/=2; s.insert(s.begin()+n,"dek"); n+=1;
s.insert(s.begin()+n,"dek");
}
for(it=s.begin(); it!=s.end(); ++it) { cout<<*it<<" ";
}
s.clear(); return 0;
}

  1. Stekda birinchi elementga teng barcha elementlar o‘chirilsin.

#include
#include
using namespace std;
void Chiqarish(stack yangi) {
while (!yangi.empty()) {
cout << yangi.top() << " ";
yangi.pop();
}
}
stack Ochirish(stack navbat, int oxiri) {
stack yangi;
while (!navbat.empty()) {
if (navbat.top() != oxiri) {
yangi.push(navbat.top());
}
navbat.pop();
}
return yangi;
}
int main() {
stack navbat;
navbat.push(5);
navbat.push(15);
navbat.push(35);
navbat.push(10);
navbat.push(10);
navbat.push(26);
navbat.push(10);
cout << "Oldin: ";
Chiqarish(navbat);
navbat = Ochirish(navbat, navbat.top());
cout << "\nKeyin: ";
Chiqarish(navbat);
return 0;
}


  1. Navbatda oxirgi elementga teng barcha elementlar o‘chirilsin.

#include


#include
#include
#include
#include
using namespace std;
void urolov(queue &st, int n)
{
int m=st.back();
bool a=true;
while(!st.empty()){
int b=st.front();
st.pop();
if(b!=m){
cout< else{ } }
cout<int main()
{
int n;
cout<<"Navbat elementlari soni qancha: ";
cin>>n;
int x[n];
queue st;
cout< for(int i=0; i cin>>x[i];
st.push(x[i]);
}
cout< urolov(st,n);
return 0;
}

109
110


111
/*111. Bir oy davomidagi kundalik temperatura berilgan bo’lsa,
oy uchun o’rtacha temperaturani hisoblash dasturini
massivdan foydalanib tuzing..*/
#include
using namespace std;
int main(){
float c=0;
int n;
cin>>n; //Oy kunlari kiritiladi.
int a[n];
for(int i=0; i cin>>a[i];
}
for(int i=0; i c += a[i];
}
cout<}

112
113


114
/*114. Bir o’lchamli massivning 10 ta elementlari ichidan
musbatlarining soni va summasini hisoblash dasturini tuzing. */
#include
using namespace std;
int main(){
int n, sum, son;
cin>>n;
int a[n];
for(int i=0; i cin>>a[i];
}
for(int i=0; i if(a[i]>0){
sum += a[i];
son ++;
}
}
cout<<"Musbat elementlari summasi: "< cout<<"Musbat elementlari soni: "<}

115
/*115. 10 ta elementdan iborat massivning eng katta,


eng kichik elementlarini va ularning o’rta qiymatini
hisoblash dasturini tuzing. */
#include
using namespace std;
int main() {
int m, o;
int a[10];
for(int i=0; i<10; i++) {
cin>>a[i];
}
for(int i=0; i<10; i++) {
for(int j=i+1; j<10; j++) {
if(a[i] swap(a[i],a[j]);
}
}
}
cout<<"Massivdagi Max element: "< cout<<"Massivdagi Min element: "< cout<<"Massivdagi Max va Min elementlari o'rta qiymati: "<<(a[0]+a[9])/2;
}

116
/*116. Bazaviy toifasi haqiqiy bo’lgan 10 ta elementli


A massivi berilgan. Juft indeksli elementlardan alohida,
toq indeksli elementlardan alohida massiv hosil qilish
dasturini tuzing. */
#include
using namespace std;
int main(){
int t=0,y=1;
int a[10], b[5],c[5];
for(int i=0; i<10; i++){
cin>>a[i];
}
for(int i=0; i<5; i++){
b[i] = a[t];
t+=2;
}
for(int i=0; i<5; i++){
c[i] = a[y];
y+=2;
}
cout<<"Xosil bo'lgan 1 - massiv"<<"\n";
for(int i=0; i<5; i++){
cout< }
cout<<"\nXosil bolgan 2 - massiv"<<"\n";
for(int i=0; i<5; i++){
cout< }
}

117
/*117. A va B massivlari berilgan. Yangi C massivini


quyidagicha hosil qiling: A massivining elementlari
yangi massivning juft indekslari, B massivining elementlari
esa yangi massivning toq indekslarini tashkil etsin. */
#include
using namespace std;
int main() {
int c, d, e, f, m=0, n=0;
cin>>c>>d;
int a[c], b[d], g[c+d];
for(int i=0; i cin>>a[i];
}
for(int i=0; i cin>>b[i];
}
for(int i=0; i<(c+d); i+=2) {
g[i] = a[m];
m ++;
}
for(int j=1; j<(c+d); j+=2) {
g[j] = b[n];
n ++;
}
for(int i=0; i<(c+d); i++) {
cout< }
}

118
/*118. Xaqiqiy toifali A va B matritsalari berilgan.


Quyidagi formula orqali yangi C matritsasini hosil
qilish dasturini tuzing: Cij = Aij + Bij; bu erda
i=1,3; j=1,2 */
#include
using namespace std;
int main() {
int n;
cout<<"Kvadrat matritsa o'lchamini kiriting: (nxn)\n";
cin>>n>>n;
cout<<"A matritsani kiriting:\n";
float a[n][n], b[n][n],c[n][n];
for(int i=0; i for(int j=0; j cin>>a[i][j];
}
}
cout<<"B matritsani kiriting:\n";
for(int i=0; i for(int j=0; j cin>>b[i][j];
}
}
for(int i=0; i for(int j=0; j c[i][j] = a[i][j] + b[i][j];
}
}
cout<<"Xosil bo'lgan C matritsa:\n";
for(int i=0; i for(int j=0; j cout< }
cout<<"\n";

}
}

119
120


121
122
123
/*123. Bir o’lchovli 10 ta elementdan iborat xaqiqiy
toifali massiv elementlarini o’sib borish tartibida
saralash dasturini tuzing. */
#include
using namespace std;
int main(){
int a[10];
for(int i=0; i<10; i++){
cin>>a[i];
}
for(int i=0; i<10; i++){
for(int j=i+1; j<10; j++){
if(a[i]>a[j]) swap(a[i],a[j]);
}
}
for(int i=0; i<10; i++){
cout< }
}

124
/*124. Bir o’lchovli 10 ta elementdan iborat xaqiqiy


toifali massiv elementlarini kamayib borish tartibida
saralash dasturini tuzing. */
#include
using namespace std;
int main(){
int a[10];
for(int i=0; i<10; i++){
cin>>a[i];
}
for(int i=0; i<10; i++){
for(int j=i+1; j<10; j++){
if(a[i] }
}
for(int i=0; i<10; i++){
cout< }
}
125
126
126.Talaba sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.
#include
using namespace std;
class talaba
{
public:
string nomi;
string familya;
int yili;
string guruhi;
string xulqi;
void input(){
cout << "talaba nomi: "; cin >> this->nomi;
cout << "talaba familyasi: "; cin >> this->familya;
cout << "Yili: "; cin >> this->yili;
cout << "guruhi : "; cin >> this->guruhi;
cout << "qulqi: "; cin >> this->xulqi;
}
void output(){
cout << "Talaba nomi:" << this->nomi << '\n';
cout << "Talaba familyasi " << this->familya << '\n';
cout << "Talaba yili: " << this->yili << '\n';
cout << "guruhi : " << this->guruhi<< '\n';
cout << "qulqi: " << this->xulqi <<'\n';
}
};
int main(){
int n;
cout << "Nechta talaba maluloti kiritamiz ?";
cin >> n;
talaba a[n];
for(int i=0;i cout << i+1 <<"-talaba ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"2003-yilda chiqarilgan tovarlar ro'yxati:\n";
for(int i=0;i if(a[i].yili==2003){
a[i].output();
}
}
}

127
127.Avtomashina sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
using namespace std;
class avtomashina
{
public:
string nomi;
string kompanyasi;
int yili;
string rangi;
int kuchi;
void input(){
cout << "avtomashina nomi: "; cin >> this->nomi;
cout << "avtomasha kompanyasi: "; cin >> this->kompanyasi;
cout << "Yili: "; cin >> this->yili;
cout << "rangi : "; cin >> this->rangi;
cout << "kuchi : "; cin >> this->kuchi;
}
void output(){
cout << "avtomashmisha nomi:" << this->nomi << '\n';
cout << "avtomashina familyasi " << this->kompanyasi << '\n';
cout << "avtomashina yili: " << this->yili << '\n';
cout << "rangi : " << this->rangi<< '\n';
cout << "kuchi: " << this->kuchi <<'\n';
}
};
int main(){
int n;
cout << "Nechta mashina maluloti kiritamiz ?";
cin >> n;
avtomashina a[n];
for(int i=0;i cout << i+1 <<"-mashina ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"2003-yilda chiqarilgan mashinalar ro'yxati:\n";
for(int i=0;i if(a[i].yili==2003){
a[i].output();
}
}
}

128
128. Mijoz sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
using namespace std;
class mijoz
{
public:
string nomi;
string familya;
int yili;
string guruhi;
string xulqi;
void input(){
cout << "mijoz nomi: "; cin >> this->nomi;
cout << "mijoz familyasi: "; cin >> this->familya;
cout << "Yili: "; cin >> this->yili;
cout << "guruhi : "; cin >> this->guruhi;
cout << "qulqi: "; cin >> this->xulqi;
}
void output(){
cout << "mijoz nomi:" << this->nomi << '\n';
cout << "mijoz familyasi " << this->familya << '\n';
cout << "mijoz yili: " << this->yili << '\n';
cout << "guruhi : " << this->guruhi<< '\n';
cout << "qulqi: " << this->xulqi <<'\n';
}
};
int main(){
int n;
cout << "Nechta mijoz maluloti kiritamiz ?";
cin >> n;
mijoz a[n];
for(int i=0;i cout << i+1 <<"-mijoz ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"2003-yilda tug`ulgan mijoz ro'yxati:\n";
for(int i=0;i if(a[i].yili==2003){
a[i].output();
}
}
}

129
129.Tovar sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
using namespace std;
class tovar
{
public:
string nomi;
string brendi;
int yili;
int ulchami;
int narxi;

void input(){
cout << "Tovar nomi: "; cin >> this->nomi;
cout << "Tovar brendi: "; cin >> this->brendi;
cout << "Yili: "; cin >> this->yili;
cout << "O'lchami: "; cin >> this->ulchami;
cout << "Narxi: "; cin >> this->narxi;
}

void output(){
cout << "Tovar nomi: " << this->nomi << '\n';
cout << "Tovar brendi: " << this->brendi << '\n';
cout << "Yili: " << this->yili << '\n';
cout << "O'lchami: " << this->ulchami << '\n';
cout << "Narxi: " << this->narxi <<'\n';
}


};
int main(){
int n;
cout << "Nechta mahsulot kiritamiz ?";
cin >> n;
tovar a[n];


for(int i=0;i cout << i+1 <<"-tovar ma'lumotlarini kiriting: \n";
a[i].input();

}


cout <<"2022-yilda chiqarilgan tovarlar ro'yxati:\n";
for(int i=0;i if(a[i].yili==2022){
a[i].output();
}


}


}

130
130. Avia reys sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
using namespace std;
class xona{
public:
string nomi;
int deraza ;
int eshik;
string shaxs;
int qavati;
void input() {
cout << " nomi: ";
cin >> this->nomi;
cout << " derazalar soni ";
cin >> this->deraza;
cout << "eshiklar soni ";
cin >> this->eshik;
cout << "masul shaxs : ";
cin >> this->shaxs ;
cout << "qavati: ";
cin >> this->qavati;
}
void output() {
cout << " nomi:" << this->nomi << '\n';
cout << " derazalar soni " << this->deraza << '\n';
cout << " eshiklar soni " << this->eshik << '\n';
cout << "masul shaxs : " << this->shaxs<< '\n';
cout << "qavati: " << this->qavati <<'\n';
}
};
int main() {
int n;
cout << "Nechta xona maluloti kiritamiz ?";
cin >> n;
xona a[n];
for(int i=0; i cout << i+1 <<"-xona ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"3-qavatdagi xonalar \n";
for(int i=0; i if(a[i].qavati==3) {
a[i].output();
}
}
}

131
131. Dars sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
using namespace std;
class xona{
public:
string nomi;
int deraza ;
int eshik;
string shaxs;
int qavati;
void input() {
cout << " nomi: ";
cin >> this->nomi;
cout << " derazalar soni ";
cin >> this->deraza;
cout << "eshiklar soni ";
cin >> this->eshik;
cout << "masul shaxs : ";
cin >> this->shaxs ;
cout << "qavati: ";
cin >> this->qavati;
}
void output() {
cout << " nomi:" << this->nomi << '\n';
cout << " derazalar soni " << this->deraza << '\n';
cout << " eshiklar soni " << this->eshik << '\n';
cout << "masul shaxs : " << this->shaxs<< '\n';
cout << "qavati: " << this->qavati <<'\n';
}
};
int main() {
int n;
cout << "Nechta xona maluloti kiritamiz ?";
cin >> n;
xona a[n];
for(int i=0; i cout << i+1 <<"-xona ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"3-qavatdagi xonalar \n";
for(int i=0; i if(a[i].qavati==3) {
a[i].output();
}
}
}

132
132.


Kompyuter sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.
#include
using namespace std;
class komputer{
public:
string nomi;
string prosesor ;
int aperativka;
string turi;
int avlodi;
void input() {
cout << " nomi: ";
cin >> this->nomi;
cout << " prosesori";
cin >> this->prosesor;
cout << "aperativka hajmi ";
cin >> this->aperativka;
cout << "turi: ";
cin >> this->turi ;
cout << "avlodi";
cin >> this->avlodi;
}
void output() {
cout << " nomi:" << this->nomi << '\n';
cout << " prosesori " << this->prosesor << '\n';
cout << " aperativka hajmi" << this->aperativka << '\n';
cout << "turi : " << this->turi<< '\n';
cout << "avlodi " << this->avlodi <<'\n';
}
};
int main() {
int n;
cout << "Nechta komputer maluloti kiritamiz ?";
cin >> n;
komputer a[n];
for(int i=0; i cout << i+1 <<"-komputer ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"11 avlod komputerlari \n";
for(int i=0; i if(a[i].avlodi==11) {
a[i].output();
}
}
}

133
133. Odam sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
using namespace std;
class odam {
public:
string nomi;
string familya;
int yili;
string guruhi;
string xulqi;
void input() {
cout << " nomi: ";
cin >> this->nomi;
cout << " familyasi: ";
cin >> this->familya;
cout << "Yili: ";
cin >> this->yili;
cout << "qon guruhi : ";
cin >> this->guruhi;
cout << "qulqi: ";
cin >> this->xulqi;
}
void output() {
cout << " nomi:" << this->nomi << '\n';
cout << " familyasi " << this->familya << '\n';
cout << " yili: " << this->yili << '\n';
cout << "qon guruhi : " << this->guruhi<< '\n';
cout << "qulqi: " << this->xulqi <<'\n';
}
};
int main() {
int n;
cout << "Nechta odam maluloti kiritamiz ?";
cin >> n;
odam a[n];
for(int i=0; i cout << i+1 <<"-odam ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"2003-yilda tug`ulgan odam ro'yxati:\n";
for(int i=0; i if(a[i].yili==2003) {
a[i].output();
}
}
}

134
134. O`quv xonasi nomli sinfni yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
using namespace std;
class xona{
public:
string nomi;
int deraza ;
int eshik;
string shaxs;
int qavati;
void input() {
cout << " nomi: ";
cin >> this->nomi;
cout << " derazalar soni ";
cin >> this->deraza;
cout << "eshiklar soni ";
cin >> this->eshik;
cout << "masul shaxs : ";
cin >> this->shaxs ;
cout << "qavati: ";
cin >> this->qavati;
}
void output() {
cout << " nomi:" << this->nomi << '\n';
cout << " derazalar soni " << this->deraza << '\n';
cout << " eshiklar soni " << this->eshik << '\n';
cout << "masul shaxs : " << this->shaxs<< '\n';
cout << "qavati: " << this->qavati <<'\n';
}
};
int main() {
int n;
cout << "Nechta xona maluloti kiritamiz ?";
cin >> n;
xona a[n];
for(int i=0; i cout << i+1 <<"-xona ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"3-qavatdagi xonalar \n";
for(int i=0; i if(a[i].qavati==3) {
a[i].output();
}
}
}

135
135.Olimlar sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
using namespace std;
class olim{
public:
string nomi;
string familya;
int yili;
string darajasi;
string xulqi;
void input() {
cout << " nomi: ";
cin >> this->nomi;
cout << " familyasi: ";
cin >> this->familya;
cout << "Yili: ";
cin >> this->yili;
cout << "ilmiy darajasi : ";
cin >> this->darajasi ;
cout << "qulqi: ";
cin >> this->xulqi;
}
void output() {
cout << " nomi:" << this->nomi << '\n';
cout << " familyasi " << this->familya << '\n';
cout << " yili: " << this->yili << '\n';
cout << "ilmiy darajsi : " << this->darajasi<< '\n';
cout << "xulqi: " << this->xulqi <<'\n';
}
};
int main() {
int n;
cout << "Nechta olim maluloti kiritamiz ?";
cin >> n;
olim a[n];
for(int i=0; i cout << i+1 <<"-olim ma'lumotlarini kiriting: \n";
a[i].input();
}
cout <<"2003-yilda tug`ulgan olim ro'yxati:\n";
for(int i=0; i if(a[i].yili==2003) {
a[i].output();
}
}
}

136


137
138
139
139.Ruchka va qalam class larini yarating va ularni bog‘lovchi funksiyalar yarating
#include
using namespace std;
class ruchka {
public:
string rangi;
int narxi;
void input() {
cout << "Qalam rangi: ";
cin >> this->rangi;
cout << "Qalam narxi: ";
cin >> this->narxi;
}

void output() {


cout << "Qalam rangi: " << this->rangi << '\n';
cout << "Qalam narxi: " << this->narxi << '\n';
}
};
class qalam {
public:
string rangi1;
int narxi1;
void input1() {
cout << "Ruchka rangi: ";
cin >> this->rangi1;
cout << "Ruchka narxi: ";
cin >> this->narxi1;
}
void output1() {
cout << "Ruchka rangi: " << this->rangi1 << '\n';
cout << "Ruchka narxi: " << this->narxi1 << '\n';
}
};
int main() {
int n;
cout << "Nechta qalam kiritamiz ?";
cin >> n;
qalam a[n];

for(int i=0; i
cout << i+1 <<"-qalam ma'lumotlarini kiriting: \n";
a[i].input1();
}
int b;
cout << "Nechta ruchka kiritamiz ?";
cin >>b ;
ruchka c[b];
for(int i=0; i cout << i+1 <<"-ruchka ma'lumotlarini kiriting: \n";
c[i].input();
}
cout <<"narxi teng bulgan ruchka va qalamlar \n";
for(int i=0; i for(int j=0; j if(a[i].narxi1==c[j].narxi) {
a[i].output1();
cout<<"\n";
c[j].output();
cout<<"\n";
}
}
}}

140
140. Kastyum va shim class larini yarating va ularni bog‘lovchi funksiyalar yarating.


#include
using namespace std;
class kastum {
public:
int ulchami;
int narxi;
void input() {
cout << "kastum ulchami: ";
cin >> this->ulchami;
cout << "kastum narxi: ";
cin >> this->narxi;
}

void output() {


cout << "kastum ulchami: " << this->ulchami << '\n';
cout << "kastum narxi: " << this->narxi << '\n';
}
};
class shim {
public:
string ulchami1;
int narxi1;
void input1() {
cout << "shim ulchami: ";
cin >> this->ulchami1; ;
cout << "shim narxi: ";
cin >> this->narxi1;
}
void output1() {
cout << "shim ulchami: " << this->ulchami1 << '\n';
cout << "shim narxi: " << this->narxi1 << '\n';
}
};
int main() {
int n;
cout << "Nechta shim kiritamiz ?";
cin >> n;
shim a[n];
for(int i=0; i cout << i+1 <<"-shim ma'lumotlarini kiriting: \n";
a[i].input1();
}
int b;
cout << "Nechta kastum kiritamiz ?";
cin >>b ;
kastum c[b];
for(int i=0; i cout << i+1 <<"-kastum ma'lumotlarini kiriting: \n";
c[i].input();
}
cout <<"narxi teng bulgan kastum va shimlar \n";
for(int i=0; i for(int j=0; j if(a[i].narxi1==c[j].narxi) {
a[i].output1();
cout<<"\n";
c[j].output();
cout<<"\n";
}
}
}
}

141
141.Kitob va daftar class larini yarating va ularni bog‘lovchi funksiyalar yarating


#include
using namespace std;
class kitob {
public:
string aftir;
int narxi;
void input() {
cout << "kitob muallifi: ";
cin >> this->aftir;
cout << "kitob narxi: ";
cin >> this->narxi;
}

void output() {


cout << "kitob muallifi: " << this->aftir << '\n';
cout << "kitob narxi: " << this->narxi << '\n';
}
};
class daftar {
public:
int beti;
int narxi1;
void input1() {
cout << "daftar betilari soni";
cin >> this->beti; ;
cout << "daftar narxi: ";
cin >> this->narxi1;
}
void output1() {
cout << "daftar betlari soni " << this->beti << '\n';
cout << "daftar narxi: " << this->narxi1 << '\n';
}
};
int main() {
int n;
cout << "Nechta daftar kiritamiz ?";
cin >> n;
daftar a[n];
for(int i=0; i cout << i+1 <<"-daftar ma'lumotlarini kiriting: \n";
a[i].input1();
}
int b;
cout << "Nechta kitob kiritamiz ?";
cin >>b ;
kitob c[b];
for(int i=0; i cout << i+1 <<"-kitob ma'lumotlarini kiriting: \n";
c[i].input();
}
cout <<"narxi teng bulgan priter va skanerlar \n";
for(int i=0; i for(int j=0; j if(a[i].narxi1==c[j].narxi) {
a[i].output1();
cout<<"\n";
c[j].output();
cout<<"\n";
}
}
}
}

142
142, Printer va skanner class larini yarating va ularni bog‘lovchi funksiyalar yarating.


#include
using namespace std;
class printer {
public:
string modeli;
int narxi;
void input() {
cout << "printer modeli: ";
cin >> this->modeli;
cout << "printer narxi: ";
cin >> this->narxi;
}

void output() {


cout << "printer modeli: " << this->modeli << '\n';
cout << "printer narxi: " << this->narxi << '\n';
}
};
class skaner {
public:
string modeli1;
int narxi1;
void input1() {
cout << "skaner modeli: ";
cin >> this->modeli1; ;
cout << "skaner narxi: ";
cin >> this->narxi1;
}
void output1() {
cout << "skaner ulchami: " << this->modeli1 << '\n';
cout << "skaner narxi: " << this->narxi1 << '\n';
}
};
int main() {
int n;
cout << "Nechta skaner kiritamiz ?";
cin >> n;
skaner a[n];
for(int i=0; i cout << i+1 <<"-skaner ma'lumotlarini kiriting: \n";
a[i].input1();
}
int b;
cout << "Nechta priter kiritamiz ?";
cin >>b ;
printer c[b];
for(int i=0; i cout << i+1 <<"-priter ma'lumotlarini kiriting: \n";
c[i].input();
}
cout <<"narxi teng bulgan priter va skanerlar \n";
for(int i=0; i for(int j=0; j if(a[i].narxi1==c[j].narxi) {
a[i].output1();
cout<<"\n";
c[j].output();
cout<<"\n";
}
}
}
}

143
143.Fleshka va disk class larini yarating va ularni bog‘lovchi funksiyalar yarating.


#include
using namespace std;
class fleshka {
public:
int ulchami;
int narxi;
void input() {
cout << "fleshka ulchami: ";
cin >> this->ulchami;
cout << "fleshka narxi: ";
cin >> this->narxi;
}

void output() {


cout << "fleshka ulchami: " << this->ulchami << '\n';
cout << "fleshka narxi: " << this->narxi << '\n';
}
};
class disk {
public:
string ulchami1;
int narxi1;
void input1() {
cout << "disk ulchami: ";
cin >> this->ulchami1; ;
cout << "disk narxi: ";
cin >> this->narxi1;
}
void output1() {
cout << "disk ulchami: " << this->ulchami1 << '\n';
cout << "disk narxi: " << this->narxi1 << '\n';
}
};
int main() {
int n;
cout << "Nechta disk kiritamiz ?";
cin >> n;
disk a[n];
for(int i=0; i cout << i+1 <<"-disk ma'lumotlarini kiriting: \n";
a[i].input1();
}
int b;
cout << "Nechta fleshka kiritamiz ?";
cin >>b ;
fleshka c[b];
for(int i=0; i cout << i+1 <<"-fleshka ma'lumotlarini kiriting: \n";
c[i].input();
}
cout <<"narxi teng bulgan fleshka va disklar \n";
for(int i=0; i for(int j=0; j if(a[i].narxi1==c[j].narxi) {
a[i].output1();
cout<<"\n";
c[j].output();
cout<<"\n";
}
}
}
}
144
144.Vector elementlarini max va min elementlarini o‘chiruvchi funksiyalar yarating.
#include
using namespace std;
int main() {
int n,temp,max,min;
cin>>n;
vectorvec;
vectorvec2;
for(int i=0; i cin>>temp;
vec.push_back(temp);
}
max= *max_element(vec.begin(), vec.end());
min= *min_element(vec.begin(), vec.end());
for(int i=0; i if(min==vec.at(i)||max==vec.at(i)){i++;}
else{ vec2.push_back(vec[i]); }}
for(int i=0; i-----------------------------------------------------------------------------------------------------------
145
145.Vectorni eng katta elementidan keyingi elementlarini chiqaruvchi va o‘chiruvchi funksiyalar yarating
#include
using namespace std;
int main() {
int n,temp,index;
cin>>n;
vectorvec;
for(int i=0; i cin>>temp;
vec.push_back(temp);
}
temp= *max_element(vec.begin(), vec.end());
for(int i=0; i if(temp==vec.at(i)){
index=i;
}
}
for(int i=index; i cout< }
for(int i=index; indexvec.pop_back();}
}

146


147
147.Berilgan vektordagi har xil elementlar soni topilsin.
#include
using namespace std;
int main() {
int n,temp;
cin>>n;
vectorvec;
setmyset;
for(int i=0; i cin>>temp;
vec.push_back(temp);
myset.insert(temp);
}
cout<<( myset.size());
}

148
148.Ikkita bir xil elementga ega bo`lgan N o`lchamli butun tipli massiv berilgan. Bir xil elementlar nomeri topilib o`sish tartibida chiqarilsin.


#include
using namespace std;
int main() {
int n;
cin>>n;
int a[n];
for(int i=0; i cin>>a[i];
}
cout<<"to`liq massiv elementlari \n";
for(int i=0 ; i cout< }
for(int i=0 ; i for(int j=i+1 ; j if(a[i]==a[j]){
cout<<"\nbir xil elementlaring indekisi "< }
}
}

149
149. N o`lchamli butun tipli massiv berilgan, hamma elementlari(o`sish yoki kamayish bo`yicha) tartiblangan. Faqat toq nomerdagi elementlari ekranga chiqarilsin,


#include
using namespace std;
int main() {
int n;
cin>>n;
int a[n];
for(int i=0; i cin>>a[i];
}
sort(a,a+n);
cout<<"to`liq massiv elementlari \n";
for(int i=0 ; i cout< }
cout<<"\n toq urindagi massiv elementlari \n";
for(int i=1 ; i cout< }
}
----------------------------------------------------------------------------------------------
150. N ta tasodifiy sonlardan iborat vector hosil qiling, elementlarini kamayish tartibida saralang.

#include


using namespace std;
int main() {
int n,a;
cin>>n;
vectorvec;
srand(time(0));
for(int i=0; i a = rand()%10000;
vec.push_back(a);
}
sort(vec.begin(),vec.end());
for(int i=0 ; i cout<}
}

150

Download 62,12 Kb.

Do'stlaringiz bilan baham:




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish