Python daturlash maktabi ๐Ÿ
574 subscribers
343 photos
180 videos
83 files
389 links
Download Telegram
2 ta roโ€™yhatning bir xil qiymatli elementlaridan yangi halqasimon roโ€™yhat yarating

#include <iostream>
using namespace std;
class Node{
public: int number;
Node* next;
};
int main()
{ Node* head = NULL;
Node* lastPtr = NULL;
short action = -1;
while (1)
{ cout<<"1. 1- guruh raqam berish\n";
cout<<"2 2-guruh raqam berish:\n";
cout<<"3. ro'yhatni ko'rish\n";
cout<<"4 ro'yxatni korish\n";
cout<<" qushish\n";
cout<<"0. chiqish\n";
cout<<"tanlang: ";
cin>>action;
if (action == 0) {
system("CLS");
break;}
if (action == 1)
{ //system("CLS");
Node* ptr = new Node;
int numb = -1;

cout<<"son kiriting: ";
cin>>numb;
ptr->number = numb;
ptr->next = NULL;
if (head == 0)
{ head = ptr;
lastPtr = ptr;
// system("CLS");
continue;
}
lastPtr->next = ptr;
lastPtr = ptr;
//system("CLS");
continue;
}
if (action == 3){
Node* ptr = NULL;
//system("CLS");
if (head == 0)
{ cout<<"\t!!! ro'yhat bo'sh !!!\n\n";
system("PAUSE");
system("CLS");
continue;
}
cout<<"* * * * * ro'yhat * * * * *\n\n";
ptr = head;
while (1) {
cout<<ptr->number<<" ";
if (ptr->next == 0) break;

ptr = ptr->next;
}
cout<<"\n\n";
system("PAUSE");
//system("CLS");
continue;
}

if (action == 2)
{ //system("CLS");
Node* ken = new Node;
int numb = -1;

cout<<"son kiriting: ";
cin>>numb;
ken->number = numb;
ken->next = NULL;
if (head == 0)
{ head = ken;
lastPtr = ken;
// system("CLS");
continue;
}
lastPtr->next = ken;
lastPtr = ken;
system("CLS");
continue;
}
if (action == 4){
Node* ken = NULL;
//system("CLS");
if (head == 0)
{ cout<<"\t!!! ro'yhat bo'sh !!!\n\n";
system("PAUSE");
system("CLS");
continue;
}
cout<<"* * * * * ro'yhat * * * * *\n\n";
ken = head;
while (1) {
cout<<ken->number<<" ";
if (ken->next == 0) break;

ken = ken->next;
}
cout<<"\n\n";
system("PAUSE");
//system("CLS");
continue;
}
if(action==5)
{
Node* qush = NULL;
system("CLS");
if (head == 0)
{ cout<<"\t!!! ro'yhatlar bo'sh !!!\n\n";
continue;
}
ken = head;
while (1) {
cout<<ken->number<<" ";
if (ken->next == 0) break;

if(ken ==prt)
{
Node* qush = new Node;
int numb = -1;

qush->number = numb;
qush->next = NULL;
if (head == 0)
{ head = qush;
lastPtr = qush;
continue;
}
lastPtr->next = qush;
lastPtr = qush;
continue;
}
}
cout<<"\n";
continue;

}
}
}
Ro'yhat Kiritilgan sonlarningn har 3chisini o`chiruvchi dastur tuzing.

Dastur kodi:
#include <bits/stdc++.h>
using namespace std;
int main() {
list <int> num_list;
int n,k;
cout<<"Nechta son kiritasiz: ";
cin>>n;
for(int i=0;i<n;i++)
{ cin>>k;num_list.push_back(k); }
size_t size = num_list.size();
cout<<"natija: ";
list <int> :: iterator it = num_list.begin();
while(size--)
{ auto toDelete = it; it++;
if (size%3==1) num_list.erase(toDelete); }
for(it = num_list.begin();
it != num_list.end(); ++it)
{ cout << *it << " "; }
cout << endl; return 0; }
Dastur natijasi:

Nechta son kiritasiz: 10
1 2 3 4 5 6 7 8 9 10
natija: 1 2 4 5 7 8 10
Forwarded from Pul Maktabi
/* 2ta nxn matitsani ko'paytirish */
#include<iostream>
#include<vector>
using namespace std;
int a[10][10],b[10][10],H[10][10];
int main(){

int n; cout<<"n: "; cin>>n;
cout<<"a["<<n<<"]["<<n<<"] : \n";
for (int i = 0; i < n; i++){
for (int j = 0; j< n; j++){
cin>>a[i][j];
}}
cout<<"b["<<n<<"]["<<n<<"] : \n";
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
cin>>b[i][j];
}}



for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
// H[i][j] = 0;
for (int t = 0; t < n; t++){
H[i][j] += a[i][t] * b[t][j];

}
}
}
cout<<"a["<<n<<"]["<<n<<"]xb["<<n<<"]["<<n<<"] :\n";
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
cout<< H[i][j]<<" " ;
}cout<<endl;
}



}
/*
15-masala. Lotoreya ishtirokchilari familiyalari va mukofotlar nomlaridan tashkil topgan 2 ta halqasimon roโ€™yhat berilgan. N ta ishtirokchi gโ€™olib boโ€™lsin (har K-inchi). Mukofotlarni qayta hisoblash soni - t.
*/
#include <bits/stdc++.h>
using namespace std;
struct Node
{
int number;
string ismi;
Node* next;
};
int n;
struct Node* head = NULL;
struct Node* lastPtr = NULL;
void qushish()
{
Node* ptr = new Node;
int numb = -1; string a;
cout<<"o'yinchi raqamini kiriting: ";
cin>>numb;
cout<<" ismini kiriting: ";
cin>>a;
ptr->number = numb;
ptr->ismi = a;
ptr->next = NULL;
if (head == 0)
{
head = ptr;
lastPtr = ptr;
}
lastPtr->next = ptr;
lastPtr = ptr;
}
void chop_etish()
{
Node* ptr = NULL;
if (head == 0)
{
cout<<"\t!!! roโ€™yhat boโ€™sh !!!\n\n";
}
cout<<"* * * * * roโ€™yhat * * * * *\n\n";

ptr = head;
while (1)
{
cout<<ptr->number<<" ";
cout<<ptr->ismi<<" \n";
if (ptr->next == 0) break;
ptr = ptr->next;}
cout<<"\n\n";}
void golib(){
Node* p1 = head;
Node* q1 = new Node;
int k=rand()%(n-1)+1;
for (int i=0;i<k-1;i++) p1=p1->next;
q1 = p1->next;
p1->next = q1->next;
cout<<" go'lib o'yinchi!:\n";
cout<<q1->number<<" ";
cout<<q1->ismi;"\n\n";
}
int main()
{
cout<<" Ro'yhat elementlari sonini kiriting:\n";
cin>>n;
cout<<" Ro'yhat elementlarini kiriting:\n";
for(int i=0;i<n;i++)
{
qushish();
}
chop_etish();
golib();
}
/*
Mahsulot nomlaridan tashkil topgan roโ€™yhat berilgan. Roโ€™yhat elementlaridagi SONY firmasida ishlab chiqilgan mahsulotlardan tashkil topgan yangi roโ€™yhat yarating.

Algoritmi:
ContainsWord nomli mantiqiy funksiya yaratish;
Undan faqat true yoki false qiymat qaytaradi.
Royhat yaratish;
Ro
yhatga malumot kiritish;
Sony so
zini malumotda qatnashganligini tekshirish;
Sony so
zi qatnashgan malumotlarni chiqarish.
*/
Dasturiy ko
rinishi:
#include "iostream"
#include "string"
#include "list"
using namespace std;
bool containsWord(string word, string inLine) {
int wlen, counter = 0, slength = inLine.length() - word.length() + 1;
wlen = word.length();

for(int i = 0; i < slength; i++) {
for(int j = 0; j < word.length(); j++){
if(word[j] == inLine[i + j])
counter++;
else{
counter = 0;
break;
}
}

if(counter == wlen) {
return true;
}
counter = 0;
}
return false;
}
main()
{
list<string> brands;
brands.push_front("Televizor-Artel");
brands.push_front("Changyutgich-Roison");
brands.push_front("Telefon-Sony");
brands.push_front("Notebook-Asus");
brands.push_front("Konditsioner-Sony");
brands.push_front("Playstation-Sony");
brands.push_front("Muzlatgich-Artel");
brands.push_front("Blender-Artel");
brands.push_front("Televizor-Sony");
brands.push_front("Notebook-Acer");

string current, brand = "Sony";
list<string> sonyBrands, bCopy = brands;

for(int i = 0; i < brands.size(); i++) {
current = bCopy.front();
if(containsWord(brand, current)) {
sonyBrands.push_front(bCopy.front());
}
bCopy.pop_front();
}

list<string> copy = sonyBrands;
cout << endl << "Sony brendi ostidagi tovarlar:" << endl << endl;
for(int i = 0; i < sonyBrands.size(); i++) {
cout << copy.front() << endl;
copy.pop_front();
}
/*

4-Variant.

Royhat yarating, Royhatga N ta haqiqiy son kiriting. Royhatning minimum elementini ochirich dasturini tuzing.

Dastur Kodi:

*/
#include <iostream>
using namespace std;

class Node{

public:

int number;

Node* next;

};

int main()
{ int n;
cout<<"Ro'yhat Elementlari sonini kiriting: \n\n";
cin>>n;
Node* head = NULL;
Node* lastPtr = NULL;
cout<<"\nRo'yhat Elementlarini kiriting: \n\n";
for(int i=0;i<n;i++){

{
Node* ptr = new Node;
int numb = -1;
cin>>numb;
ptr->number = numb;
ptr->next = NULL;
if (head == 0)
{ head = ptr;
lastPtr = ptr;

continue;
}
lastPtr->next = ptr;
lastPtr = ptr;

continue; } }
{
Node* ptr = NULL;

if (head == 0)
{
cout<<"\t!!! Ro'yhat bosh !!!\n\n";
system("PAUSE");

}
cout<<"\nRo'yhat minimal elementlari o'chirildi!: \n\n";
ptr = head;
int min=ptr->number;
Node* q = new Node;
while(ptr){
if(min>ptr->number){ min=ptr->number;}
ptr=ptr->next; }
ptr = head;
while (1) {
if(min==ptr->number) {
delete(ptr);}
else cout<<ptr->number<<" ";
if (ptr->next == 0) break;
ptr = ptr->next; }

cout<<"\n\n";
system("PAUSE"); } }
#include <iostream>
#include <cstdlib>
using namespace std;

class BinarySearchTree
{
private:
struct tree_node
{
tree_node* left;
tree_node* right;
int data;
};
tree_node* root;
public:
BinarySearchTree()
{
root = NULL;
}
bool isEmpty() const { return root==NULL; }
void print_inorder();
void inorder(tree_node*);
void print_preorder();
void preorder(tree_node*);
void print_postorder();
void postorder(tree_node*);
void insert(int);
void remove(int);
};

// kichkina elementi chap tarafga joylashtiriladi

// kattaroq elementi o'ng tarafga joylashtiriladi
void BinarySearchTree::insert(int d)
{
tree_node* t = new tree_node;
tree_node* parent;
t->data = d;
t->left = NULL;
t->right = NULL;
parent = NULL;
// bu yangi daraxtmi?
if(isEmpty()) root = t;
else
{
// Izoh: HAMMA qo'shimchalar barg tugunlari kabi
tree_node* curr;
curr = root;
// Find the Node's parent
while(curr)
{
parent = curr;
if(t->data > curr->data) curr = curr->right;
else curr = curr->left;
}

if(t->data < parent->data)
parent->left = t;
else
parent->right = t;
}
}

void BinarySearchTree::remove(int d)
{
// Elementni toping
bool found = false;
if(isEmpty())
{
cout<<" This Tree is empty! "<<endl;
return;
}
tree_node* curr;
tree_node* parent;
curr = root;
while(curr != NULL)
{
if(curr->data == d)
{
found = true;
break;
}
else
{
parent = curr;
if(d>curr->data) curr = curr->right;
else curr = curr->left;
}
}
if(!found)
{
cout<<" Bunday son mavjud emas! "<<endl;
return;
}


/*// 3 ta holat:
// 1. Biz barg tugunini olib tashlaymiz
// 2. Biz bitta bola bilan tugunni olib tashlaymiz
// 3. biz 2 bolali tugunni olib tashlaymiz

// Bitta bolali tugun*/
if((curr->left == NULL && curr->right != NULL)|| (curr->left != NULL
&& curr->right == NULL))
{
if(curr->left == NULL && curr->right != NULL)
{
if(parent->left == curr)
{
parent->left = curr->right;
delete curr;
}
else
{
parent->right = curr->right;
delete curr;
}
}
else // chap bola hozir, o'ng bola yo'q
{
if(parent->left == curr)
{
parent->left = curr->left;
delete curr;
}
else
{
parent->right = curr->left;
delete curr;
}
}
return;
}

//We're looking at a leaf node
if( curr->left == NULL && curr->right == NULL)
{
if(parent->left == curr) parent->left = NULL;
else parent->right = NULL;
delete curr;
return;
}



/* 2 farzandli tugun
// tugmani o'ng pastki satrda eng kichik qiymat bilan almashtirish */
if (curr->left != NULL && curr->right != NULL)
{
tree_node* chkr;
chkr = curr->right;
if((chkr->left == NULL) && (chkr->right == NULL))
{
curr = chkr;
delete chkr;
curr->right = NULL;
}
else // o'ng farzandning bolalari bor
{
/* agar tugunning o'ng bolasida chap bolasi bo'lsa
// Kichkina elementni topish uchun chap tomonga pastga siljiting*/
๐Ÿ‘1
if((curr->right)->left != NULL)
{
tree_node* lcurr;
tree_node* lcurrp;
lcurrp = curr->right;
lcurr = (curr->right)->left;
while(lcurr->left != NULL)
{
lcurrp = lcurr;
lcurr = lcurr->left;
}
curr->data = lcurr->data;
delete lcurr;
lcurrp->left = NULL;
}
else
{
tree_node* tmp;
tmp = curr->right;
curr->data = tmp->data;
curr->right = tmp->right;
delete tmp;
}

}
return;
}

}

void BinarySearchTree::print_inorder()
{
inorder(root);
}

void BinarySearchTree::inorder(tree_node* p)
{
if(p != NULL)
{
if(p->left) inorder(p->left);
cout<<" "<<p->data<<" ";
if(p->right) inorder(p->right);
}
else return;
}

void BinarySearchTree::print_preorder()
{
preorder(root);
}

void BinarySearchTree::preorder(tree_node* p)
{
if(p != NULL)
{
cout<<" "<<p->data<<" ";
if(p->left) preorder(p->left);
if(p->right) preorder(p->right);
}
else return;
}

void BinarySearchTree::print_postorder()
{
postorder(root);
}

void BinarySearchTree::postorder(tree_node* p)
{
if(p != NULL)
{
if(p->left) postorder(p->left);
if(p->right) postorder(p->right);
cout<<" "<<p->data<<" ";
}
else return;
}

int main()
{
BinarySearchTree b;
int ch,tmp,tmp1;
while(1)
{
cout<<endl<<endl;
cout<<" Binary izlash daraxti operatsiyalari "<<endl;
cout<<" ----------------------------- "<<endl;
cout<<" 1. Insertion/Creation "<<endl;
cout<<" 2. In-Order Traversal "<<endl;
cout<<" 3. Pre-Order Traversal "<<endl;
cout<<" 4. Post-Order Traversal "<<endl;
cout<<" 5. Removal "<<endl;
cout<<" 6. Exit "<<endl;
cout<<" Tanlash uchun raqam kiriting : ";
cin>>ch;
switch(ch)
{
case 1 : cout<<" Qo'shish uchun son kiriting : ";
cin>>tmp;
b.insert(tmp);
break;
case 2 : cout<<endl;
cout<<" In-Order Traversal "<<endl;
cout<<" -------------------"<<endl;
b.print_inorder();
break;
case 3 : cout<<endl;
cout<<" Pre-Order Traversal "<<endl;
cout<<" -------------------"<<endl;
b.print_preorder();
break;
case 4 : cout<<endl;
cout<<" Post-Order Traversal "<<endl;
cout<<" --------------------"<<endl;
b.print_postorder();
break;
case 5 : cout<<" kiritilgan son o'chiriladi' : ";
cin>>tmp1;
b.remove(tmp1);
break;
case 6 : system("pause");
return 0;
break;
}
}
}
In-Order Traversal

Pre-Order Traversal

Post-OrderTravers
al
Python juda ko'p loyihalarda ishlatilgan.

Veb-dasturlash
โ–ช๏ธZope โ€” CMS yaratish uchun server va veb dasturlar qilish uchun dastur.
โ–ช๏ธDjango โ€” web yaratish qilish uchun dastur.
โ–ช๏ธTurbogears โ€” web yaratish qilish uchun dastur.
โ–ช๏ธCherryPy โ€” web yaratish qilish uchun dastur.
โ–ช๏ธPlone โ€” saytni muhofaza qilish uchun dastur.
โ–ช๏ธMailman โ€” โ€žRassilkaโ€œ yaratish uchun dastur
โ–ช๏ธMoinMoin โ€” viki โ€” dvijok internet va intranet uchun.
โ–ช๏ธPlanetPlanet โ€” RSS oqimini sindikatsiyalash.

Grafika
โ–ช๏ธSkencil โ€” Vektor grafikasi uchun dastur.

Pythonni ishlatadigan dasturlar
โ–ช๏ธWikipedia โ€” botlarni yozish uchun ishlatadi.
โ–ช๏ธCivilization IV โ€” Yaxshi strategiya oสปyin.

Pythonni ishlatadigan kompaniyalar
โ–ช๏ธKosmik teleskop instituti
โ–ช๏ธNASA
โ–ช๏ธGoogle
โ–ช๏ธDreamWorks
โ–ช๏ธIndustrial Light & Magic
โ–ช๏ธFiraxis Games
โ–ช๏ธApple Computer
โ–ช๏ธCCP


๐ŸŒ @uz_python
๐Ÿ˜ฒBiz foydalanayotgan Telegram messenjeri 1985-yilda yaratilgan inson tiliga yaqin va mukammal bo'lgan C++ dasturlash tilida yozilgan...

๐Ÿ‘‰ @uz_python ๐Ÿ‘ˆ