Python daturlash maktabi 🐍
573 subscribers
343 photos
180 videos
83 files
389 links
Download Telegram
#Javob10


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
struct node
{
float key;
struct node *left, *right;
};
struct node *newNode(float item)
{
struct node *temp = (struct node *)malloc(sizeof(struct node));
temp->key = item;
temp->left = temp->right = NULL;
return temp;
}
void inorder(struct node *root)
{
if (root != NULL)
{
inorder(root->left);
printf("%g ", root->key);
inorder(root->right);
}
}
struct node* insert(struct node* node, float key)
{
if (node == NULL) return newNode(key);
if (key < node->key)
node->left = insert(node->left, key);
else
node->right = insert(node->right, key);
return node;
}
struct node * minValueNode(struct node* node)
{
struct node* current = node;
while (current && current->left != NULL)
current = current->left;
return current;
}
struct node* deleteNode(struct node* root, float key)
{
if (root == NULL) return root;
if (key < root->key)
root->left = deleteNode(root->left, key);
else if (key > root->key)
root->right = deleteNode(root->right, key);
else
{
if (root->left == NULL)
{
struct node *temp = root->right;
free(root);
return temp;
}
else if (root->right == NULL)
{
struct node *temp = root->left;
free(root);
return temp;
}
struct node* temp = minValueNode(root->right);
root->key = temp->key;
root->right = deleteNode(root->right, temp->key);
}
return root;
}

int main()
{

struct node *root = NULL;

printf("Daraxt tugunlari soni: ");
int n;
cin>>n;
printf("Daraxt tugunlarini kiriting: \n");
float s=0;
for(int i=0; i<n; i++)
{
float temp;
cin>>temp;
s += temp;
root = insert(root, temp);
}
s /= n;
printf("\nDaraxtning tugunlari qiymatlarining orta arifmetigi: %g\n\n",s);

root = insert(root, s);
printf("Daraxtga %g qiymatli tugun qo
shildi ! \n\n",s);

inorder(root);
return 0;
}
Python daturlash maktabi 🐍
#Savol10
#Javob10.2


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
struct node
{
float key;
struct node *left, *right;
};
struct node *newNode(float item)
{
struct node *temp = (struct node *)malloc(sizeof(struct node));
temp->key = item;
temp->left = temp->right = NULL;
return temp;
}
void inorder(struct node *root)
{
if (root != NULL)
{
inorder(root->left);
printf("%g ", root->key);
inorder(root->right);
}
}
void node_view(struct node *root)
{
if (root != NULL)
{

printf("%f ", root->key);
}
}
struct node* insert(struct node* node, float key)
{
if (node == NULL) return newNode(key);
if (key < node->key)
node->left = insert(node->left, key);
else
node->right = insert(node->right, key);
return node;
}
struct node * minValueNode(struct node* node)
{
struct node* current = node;
while (current && current->left != NULL)
current = current->left;
return current;
}
struct node* deleteNode(struct node* root, float key)
{
if (root == NULL) return root;
if (key < root->key)
root->left = deleteNode(root->left, key);
else if (key > root->key)
root->right = deleteNode(root->right, key);
else
{
if (root->left == NULL)
{
struct node *temp = root->right;
free(root);
return temp;
}
else if (root->right == NULL)
{
struct node *temp = root->left;
free(root);
return temp;
}
struct node* temp = minValueNode(root->right);
root->key = temp->key;
root->right = deleteNode(root->right, temp->key);
}
return root;
}

int main()
{

struct node *root = NULL;

printf("Daraxt tugunlari soni: ");
int n;
cin>>n;
printf("Daraxt tugunlarini kiriting: \n");
for(int i=0; i<n; i++)
{
float temp;
cin>>temp;
root = insert(root, temp);
}
inorder(root);
cout<<endl;
struct node *t_left = root->left;
struct node *t_right = root->right;
if((root->key)-(t_left->key) < (t_right->key)-(root->key)){
node_view(t_left);
}
else{
node_view(t_right);
}
return 0;
}
This media is not supported in your browser
VIEW IN TELEGRAM
Barcha IT soxasida talim olayotganlar yani TATU da o'qiyotgan ko'pchilik 50-60% Talabalarga uy vazifa (deadline) va mustaqil ishlar ko'payib unga vaqti yetmayapti yoki uni Bajara olmayotkanlar uchun xam biz ularga yordam qilamiz. ( Kelishuv asosida muddat va misolni qiyinlik darajasi bo'yicha ishlab beradigon, bizda tajribali dasturchilar mavjud )
Murojat uchun :
Admin: @Frozen_ice
Channel: @uz_python
Python daturlash maktabi 🐍
Photo
2)

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
struct node
{
int key;
struct node *left, *right;
};
struct node *newNode(int item)
{
struct node *temp = (struct node *)malloc(sizeof(struct node));
temp->key = item;
temp->left = temp->right = NULL;
return temp;
}
int height(node *tree, int d){
if (tree->key == d) return 0;
else {
if (d > tree->key) return height(tree->right,d)+1;
else return height(tree->left,d)+1;
}
}
int intrave(node *tree){
if(tree!=NULL) {
intrave(tree->left);
cout<<tree->key<<" ";
intrave(tree->right);
}
return 0;
}


struct node* insert(struct node* node, int key)
{
if (node == NULL) return newNode(key);
if (key < node->key)
node->left = insert(node->left, key);
else
node->right = insert(node->right, key);
return node;
}


int main()
{

struct node *root = NULL;

printf("Daraxt tugunlari soni: ");
int n;
cin>>n;
printf("Daraxt tugunlarini kiriting: \n");

for(int i=0; i<n; i++)
{
float temp;
cin>>temp;
root = insert(root, temp);
}
int a;
cout<<"Kerakli tugun kalit qiymatini kiriting: "; cin>>a;

intrave(root);
cout<<endl;
cout<<"Berilgan tugungacha masofa: "<<height(root,a);

return 0;
}
Python daturlash maktabi 🐍
Photo
2)


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
struct node
{
int key;
struct node *left, *right;
};
int arr[12];
int i=0,k=0;
struct node *T = NULL;
struct node *newNode(int item)
{
struct node *temp = (struct node *)malloc(sizeof(struct node));
temp->key = item;
temp->left = temp->right = NULL;
return temp;
}

int pretrave(node *tree){
if(tree!=NULL) {int a=0,b=0;
if(tree->left!=NULL) a=tree->left->key;
if(tree->right!=NULL) b=tree->right->key;
cout<<tree->key<<" - chapida "<<a<<" - o`ngida "<<b<<" \n";
pretrave(tree->left);
pretrave(tree->right);
}
return 0;
}

int intrave(node *tree){
if(tree!=NULL) {
intrave(tree->left);
arr[i++]=tree->key;
intrave(tree->right);
}
return 0;
}

node *new_tree(int *arr, int start, int end){
if(start>end) return NULL;
else {
int mid=(start+end)/2;
node *tree=new node;
tree->key=arr[mid];
tree->left=new_tree(arr,start,mid-1);
tree->right=new_tree(arr,mid+1,end);
return tree;
}
}

struct node* insert(struct node* node, int key)
{
if (node == NULL) return newNode(key);
if (key < node->key)
node->left = insert(node->left, key);
else
node->right = insert(node->right, key);
return node;
}
void insert_terminal(struct node *root)
{
if (root != NULL)
{
insert_terminal(root->left);
if(root->left == NULL && root->right == NULL){
T = insert(T,root->key);
k++;
}
insert_terminal(root->right);
}
}


int main()
{

struct node *root = NULL;

printf("Daraxt tugunlari soni: ");
int n;
cin>>n;
printf("Daraxt tugunlarini kiriting: \n");

for(int i=0; i<n; i++)
{
float temp;
cin>>temp;
root = insert(root, temp);
}

pretrave(root);
cout<<endl;
cout<<endl;


insert_terminal(root);
intrave(T);
T = new_tree(arr,0,k-1);

pretrave(T);
return 0;
}
#Savol1
1.Ketma-ket qidiruv usulidan foydalanib, ro‘yhatda berilgan kalitdan katta elementlarni toping
#include<iostream>
#include<list>
using namespace std;
int main(){

list <int> a;
for(int i=0;i<10;i++){

a.push_back(i+1);
}
int kalit;
cin>>kalit;

cout<<"Ro'yxat:\n";
for(int i:a){
cout<<i<<" ";}
cout<<endl;
for(int i:a){
if(i>kalit)
cout<<i<<" ";
}
}
This media is not supported in your browser
VIEW IN TELEGRAM
😁😁😁Dasturlashni endi boshlaganingda shunday bo'lishi mumkin lekin sen aslo chekinma👍👍
@BekorchiStudentlar
@uz_python
Forwarded from Bคгคt๏ש (๏ŦŦเςเคl) ✔
MTA laboratoriya MI 3.docx
47.4 KB
Оёқ кийимингизнинг размери охирига 2 та (0) қўшинг, ундан туғилган йилингизни айириб юборинг . Унга ҳозирги йилни қўшинг. Охирги 2 та сон сизнинг ёшингиз!
@uz_python
•┈•┈•✿••❁📖❁••✿•┈•┈•
Forwarded from Deleted Account
/*

RO’YHAT har ikkinchi elementi o’chirilsin.

*/

#include <bits/stdc++.h>
using namespace std;
int main() {

list <int> num_list;

int n,k;
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%2==1) num_list.erase(toDelete); }

for(it = num_list.begin();
it != num_list.end(); ++it)
{ cout << *it << " "; }
cout << endl; return 0; }
Forwarded from Deleted Account
Forwarded from Deleted Account
/*

Stek elementlari teskari tartibda joylashtirib chiqilsin.

*/


#include<bits/stdc++.h>
using namespace std;
stack<char> st;
string ns;
char pastki_qismiga_joylashtir(char x)
{
if(st.size() == 0)
st.push(x);
else
{
char a = st.top();
st.pop();
pastki_qismiga_joylashtir(x);
st.push(a);
}
}
char teskari()
{
if(st.size()>0)
{
char x = st.top();
st.pop();
teskari();

pastki_qismiga_joylashtir(x);
}
}
int main()
{ st.push('1');
st.push('2');
st.push('3');
st.push('4');
cout<<"Asosiy Stack"<<endl;
cout<<"1"<<" "<<"2"<<" "
<<"3"<<" "<<"4"
<<endl;
teskari();
cout<<"teskari Stack"
<<endl;

while(!st.empty())
{

char p=st.top();
st.pop();
ns+=p; }

cout<<ns[3]<<" "<<ns[2]<<" "

<<ns[1]<<" "<<ns[0]<<endl;
return 0;
}
Forwarded from Deleted Account
Forwarded from Deleted Account
#include <iostream>
#include<deque>
///Navbat juft elementlari o'chirilsin
using namespace std;

int main()
{
deque <int> navbat1,navbat;
int n;
cout<<"n= "; cin>>n;
cout<<"navbat elementlarini kiriting: ";
for(int i=0;i<n;i++)
{ int k;
cin>>k;
navbat.push_back(k);
}
int k=0;
for(int i:navbat)
{
if(k%2==0) navbat1.push_back(i);
k++;
navbat.pop_front();
}cout<<"\n navbat juft o'rnidagi elementlari o'chirilsin: ";
for(int j:navbat1)
{
cout<<j<<" ";
}

return 0;
}
image_2019-11-16_22-26-56.png
2.9 KB
#include <iostream>
#include<deque>
using namespace std;

int main()
{
deque <int> navbat1,navbat;
int n;
cout<<"n= "; cin>>n;
cout<<"navbat elementlarini kiriting: ";
for(int i=0;i<n;i++)
{ int k;
cin>>k;
navbat.push_back(k);
}
int k=0;
int min=navbat.front();
for(int i:navbat)
{ if(i<min)min=i;
}
for(int i:navbat)
{
if(i==min) navbat1.push_back(0);
else navbat1.push_back(i);
k++;
navbat.pop_front();
}

cout<<"\n navbatni minimal elementi o'rniga 0 joylashtirilsin: ";
for(int j:navbat1)
{
cout<<j<<" ";
}

return 0;
}