Bajardi: Norqulova Dilbar Guruh: swd015-L3 1-Misol: Kastyum va shim
Download 374.3 Kb.
|
1-laboratoriya ishi dasturlashdan
- Bu sahifa navigatsiya:
- Ajdod class va uning maydonlari Voris class va uning maydonlari (belgilangan maydon, ajdod class maydonlaridan foydalangan holda)
Bajardi: Norqulova Dilbar Guruh: SWD015-L3 9.1-Misol: Kastyum va shim class larini yarating va ularni bog’lovchi funksiyalar yarating. #include #include using namespace std; namespace OverLoad { class Kostyum { public: string rangi, davlati; int olchami, narxi; void set(std::string R, std::string D, int O, int N) { rangi = R; davlati = D; olchami = O; narxi = N; } void get() { cout<<"Rangi: "< cout<<"Ishlab chiqaruvchi davlat nomi: "< cout<<"O'lchami: "< cout<<"Narxi: "< cout< class Shim { public:
string rangi, firmasi; int olchami, narxi;
void set(string R,string F, int O, int N) { rangi = R;
firmasi = F; olchami = O;
narxi = N; } void get()
{ cout<<"Rangi: "< cout<<"Ishlab chiqaruvchi firma nomi: "< cout<<"O'lchami: "< cout<<"Narxi: "< cout< template { cout<<"Qidirilayotgan rangini kiriting: "< string s; cin>>s;
bool bor=false; for(int i=0; i { if(t[i].rangi.compare(s)==0){ bor=true; t[i].get(); }}
if(!bor) cout<<"Bunday ranglisi yo'q"< cout< template { cout<<"Rangi bo'yicha saralanganda: \n";
X temp;
if(t[i].rangi.compare(t[j].rangi)>0){
temp = t[i]; t[i] = t[j]; t[j] = temp; }}} for(int i=0; i { t[i].get(); } cout< int main () { cout<<"\t\t Kostyum ma'lumotlari:"< string rangi[]={"qora", "oq", "ko'k"}; string davlati[]={"O'zbekiston", "Xitoy", "Germaniya"};
int olchami[]={50, 55, 60}; int narxi[]={100000, 200000, 300000};
OverLoad::Kostyum k[100]; for ( int i=0; i<3; i++)
{ k[i].set(rangi[i], davlati[i], olchami[i], narxi[i]); k[i].get(); }
cout< OverLoad::Qidirish(k, 3);
OverLoad::Saralash(k, 3); cout<<"\t\t Shimning ma'lumotlari:"< string rangi1[]={"yashil", "pushti", "moviy"}; string firmasi1[]={"Nike", "Gap", "Adidas"};
int olchami1[]={40, 45, 50}; int narx1[]={600000, 700000, 800000};
OverLoad::Shim s[100]; for (int i=0; i<3; i++){
s[i].set(rangi1[i], firmasi1[i], olchami1[i], narx1[i]); s[i].get();
} cout< OverLoad::Qidirish(s,3);
OverLoad::Saralash(s,3); } 9.2-Misol: FIO, maoshi, ishga kirgan yili |
ma'muriyatiga murojaat qiling