return p;
}
K1 karta K2 kartani uradimi yoki yo’qmi.
//---------------------------------------------------------------------------
#include
#include
#include
#pragma hdrstop
#pragma argsused
//--------------------------------------------------------------------------
enum rasm {piki,trefi,bubni,chervi};
enum nom {olti,etti,sakkiz,toqqiz,on,valet,dama,karol,tuz};
struct karta {
rasm r;
nom n;
};
//-------------------------------------------------------------------------
bool uradi(karta k1,karta k2,rasm kz);
//-------------------------------------------------------------------------
int main(int argc, char* argv[])
{
rasm kz;
karta k1,k2;
k1.n=karol; k1.r=piki;
k2.n=dama; k2.r=piki;
kz=piki;
if (uradi(k1,k2,kz)) cout<<" uradi ";
else cout<<" urmaydi ";
getch();
return 0;
}
//---------------------------------------------------------------------------
bool uradi(karta k1,karta k2,rasm kz)
{ bool t=false;
if((k1.r==k2.r) && (k1.n>k2.n)) t=true;
if ((k1.r==kz) && (k2.r!=kz)) t=true;
if ((k2.r==kz) && (k1.r==kz) && (k1.n>k2.n)) t=true;
return t;
}
Ma'ruza 2. Algoritmlarni tahlil qilish
"A" shahardan "B" shaharga borish uchun uni turli yo'llar bilan amalga oshirish mumkin: samolyotda, avtobusda, poezdda, shuningdek velosipedda.
Qulayligiga qarab, bizga maqul bo’lgan yo’lni tanlaymiz .
Xuddi shunday, informatikada ham bir xil masalani echish uchun bir nechta algoritmlar mavjud (masalan, saralash masalasida insert sort, select sort, quick sort va boshqalar kabi ko'plab algoritmlar mavjud ) .
Algoritmlarni tahlili qaysi algoritm egallagan vaqt va makon jihatidan eng samarali ekanligini aniqlashga yordam beradi .
Algoritm tahlilining maqsadi algoritmlarni (yoki echimlarni) asosan ish vaqti va boshqa omillar (masalan, xotira hajmi, algoritmning murakkabligi va boshqalar) bo'yicha taqqoslashdir .