Public: int info
Download 28 Kb.
|
Dastur 2-3.
#include #include using namespace std; class node { public:
int info; node *left; node *right; }; int intrave(node *tree) { if (tree!=NULL) { int a=0, b=0; if (tree->left!=NULL) { a=tree->left->info; } if (tree->right!=NULL) { b=tree->right->info; } cout< intrave(tree->left);
intrave(tree->right); }
return 0; node *del(node *tree,int key) { node *p=new node; node *next=tree; node *q=NULL; while (next!=NULL) { if (next->info==key) { cout<<"Binar daraxtda "< p=next;
break;
if (next->info>key) { q=next;
next=next->left; } else { q=next;
next=next->right; } } if (next==NULL) cout<<"tuzilmada izlangan element yo‟q!!!"< node *v=NULL,*t=NULL,*s=NULL; if (p->left==NULL) v=p->right; else if (p->right==NULL) v=p->left; if ((p->left!=NULL)&&(p->right!=NULL)) { t=p; v=p->right; s=v->left; } while (s!=NULL) { t=v;
v=s; s=v->left; } if ((t!=NULL)&&(t!=p)) { t->left=v->right; v->right=p->right; v->left=p->left; } if (t==p) v->left=p->left; if (q==NULL) { cout< tree=v; delete(p); return tree; } if (p==q->left) q->left=v; else q->right=v; delete(p); // o’chirilgan element joylashgan xotira yacheykasini tozalash return tree; } int main() { int n,key,s; node *tree=NULL,*next=NULL; cout<<"n="; cin>>n; for (int i=0; i node *p=new node; node *last=new node; cin>>s;
p->info=s; p->left=NULL; p->right=NULL; if (i==0) { tree=p;
next=tree; continue; } next=tree; while (1) { last=next; if (p->info next=next->left; else next=next->right; if(next==NULL)break; } if (p->info last->left=p; else
last->right=p; } cout< cout<<"delete qilinadigan elementni kiriting \n"; cout<<"key="; cin>>key; tree=del(tree,key); intrave(tree); getch(); } #include #include #include #include using namespace std; struct Talaba{ string Name; int age; int Mat_ball; int Mtv_A; int PRog; int Fiz; int Ses_ball; }; int main(){ int n; cout << " Talabalar soni -> "; cin >> n; Talaba ruyxat[n]; cout << " \n"; for(int i=0; i < n; i++){ cout << i + 1 << " - talaba: "< cout << " Ismi Familiyasi -> "; cin >> ruyxat[i].Name;
cout << " Tug'ilgan yili -> "; cin >> ruyxat[i].age; cout << " Matematika bo'yicha bahosi -> "; cin >> ruyxat[i].Mat_ball;
cout << " Malumotlar tuzilmasi bahosi -> "; cin >> ruyxat[i].Mtv_A; cout << " Dasturlash bahosi -> "; cin >> ruyxat[i].PRog;
cout << " Fizikadan bahosi -> "; cin >> ruyxat[i].Fiz; cout << " Sessiya balli -> "; cin >> ruyxat[i].Ses_ball;
}
for(int i=0; i < n; i++){ if ( ruyxat[i].Mtv_A < ruyxat[j].Mtv_A){ swap(ruyxat[i], ruyxat[j]); } } }; cout << " \n"; cout << " Tartiblangan ro'yxat "; cout << " \n"; for(int i=0; i < n; i++){ cout << i + 1 << " - talaba: "< cout << " Ismi Familiyasi -> " << ruyxat[i].Name << endl;
cout << " Tug'ilgan yili -> " << ruyxat[i].age << endl; cout << " Matematika bo'yicha bahosi -> " << ruyxat[i].Mat_ball << endl;
cout << " Malumotlar tuzilmasi bahosi -> " << ruyxat[i].Mtv_A << endl; cout << " Dasturlash bahosi -> " << ruyxat[i].PRog << endl;
cout << " Fizikadan bahosi -> " << ruyxat[i].Fiz << endl; cout << " Sessiya balli -> " << ruyxat[i].Ses_ball << endl;
}
return 0; #include using namespace std; int main(){ int n; cout <<" Massiv elementlari soni -> "; cin >> n; int arr[n]; for(int i = 0; i < n; i++){ cout << " arr[" << i << "] = "; cin >> arr[i]; } int l=0; for(int i = 0; i < n - 1; i++){ if( (arr[i] - arr[i+1]) % 2 == 0 && arr[i] % 3 == 0){ cout << " a["< "; cout << arr[i]; l++; cout << endl; } } if(l == 0){ cout << " Bunday elementlar mavjud emas! "; }
} Download 28 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling