27-laboratoriya ishi topshiriqlari. To’g’ri tanlov usuli


Download 71.45 Kb.
Sana02.01.2022
Hajmi71.45 Kb.
#198275
Bog'liq
27-labaratoriya ishi Sarvar Maxmudov


941-19-guruh talabasi Sarvar Mamxudov

27-laboratoriya ishi topshiriqlari.

To’g’ri tanlov usulidan foydalanib, saralashni amalga oshirish dasturini ishlab chiqing (variantga mos ravishda):

10.Talabalar familiyalarini alifbotartibida.

27-laboratoriya 10-topshiriq

#include

using namespace std;

void s_sort(string s[], int n) {

int i,j,x;

for(i=0; i

x=i;

for(j=i+1; j

if(s[j]

swap(s[i],s[x]);

}

}

int main() {



int i,n;

cout<<"Talabalar sonini kiriting:"; cin>>n;

string s[n];

cout<

for(i=0; i

cout<

cin>>s[i]; }

s_sort(s, n);

cout<<"Tartiblangandan keyingi xolat:\n";

for(i=0; i

system("pause");

return 0;

}

14. Talabalarni birinchi imtihoni natijasi bo’yicha o’sishtartibida.



//27-laboratoriya 14-topshiriq

#include

using namespace std;

void s_sort(string s[], float b[], int n) {

int i,j,x;

for(i=0; i

for(j=i+1; j

swap(s[i],s[x]); swap(b[i],b[x]); }

}

int main() {



int i,n;

cout<<"Talabalar sonini kiriting:"; cin>>n;

string s[n];

float b[n];

for(i=0; i

cout<>s[i];

cout<<"1-imtihondan to'plagan bali:"; cin>>b[i];

} s_sort(s,b,n);

cout<<"Tartiblangandan keyingi xolat:\n";

for(i=0; i

system("pause");

return 0;



}

18. Talabalarni birinchi va ikkinchi imtihoni natijalari bo’yicha o’sish tartibida.

//27-laboratoriya ishi 18-topshiriq

#include

using namespace std;

struct talaba{

char fam[32];

float b1;

float b2;

void set(char _f[32],float _b1,float _b2) {

strcpy(fam, _f); b1=_b1; b2=_b2;

}

void show() {



cout<

}

};



int main() {

int i,j,k,n;



cout<<"Talabalar soni:"; cin>>n;

talaba t[n];

char _f[32];

float _b1,_b2;

for(i=0; i

cin.getline(_f,32);

cout<

cin.getline(_f,32);

cout<<"1-imtihondan olgan bali:"; cin>>_b1;

cout<<"2-imtihondan olgan bali:"; cin>>_b2;

t[i].set(_f,_b1,_b2);

}

//b1 bo'yicha saralash



for(i=0; i

for(j=i+1; j

if(t[j].b1

swap(t[i],t[k]);

}

//b2 bo'yicha saralash



for(i=0; i

for(j=i+1; j

if(t[j].b1==t[k].b1 && t[j].b2

swap(t[i],t[k]);

}

cout<<"Tartiblangandan keyingi xolati:\n";



for(i=0; i

cout<

}

system("pause");



return 0;

}

10



#include

#define RED RGB(255,0,0)

#define GRN RGB(0,255,0)

#define BLU RGB(0,0,255)

#define BLK RGB(0,0,0)

#define WHT RGB(255,255,255)

HPEN getPen(intiPEN_STYLE, intiPEN_SIZE, intiCOLORREF);

BOOL SetPoint(HDC hDC, HPEN hPen, COORD PNT);

BOOL PlotLine(HDC hDC, HPEN hPen, COORD BGN, COORD END);

BOOL PlotRect(HDC hDC, HPEN hPen, COORD BGN, COORD END);

BOOL PlotCirc(HDC hDC, HPEN hPen, COORD BGN, COORD END);

COORD setCordScale(COORD POS, RECT pRECT);

int main(){

HWND hWnd = GetForegroundWindow();

HPEN RPEN = getPen(PS_SOLID, 2, RED);

HPEN GPEN = getPen(PS_SOLID, 2, GRN);

HPEN BPEN = getPen(PS_SOLID, 2, BLU);

HPEN WPEN = getPen(PS_SOLID, 3, WHT);

RECT pRECT= {0};

COORD POS = {0};

COORD BGN =setCordScale(POS,pRECT);

GetWindowRect(hWnd,&pRECT);

HDC hDC = GetWindowDC(hWnd);

if(hDC){


SetBkMode(hDC,TRANSPARENT);

SetPoint (hDC, WPEN, BGN);

POS.X = BGN.X + 50;

POS.Y = BGN.Y + 100;

PlotRect(hDC, BPEN, BGN, POS);

PlotLine(hDC, RPEN, BGN, POS);

SetPoint (hDC, WPEN, BGN);

BGN = POS;

POS.X = BGN.X + 100;

POS.Y = BGN.Y + 100;

PlotCirc(hDC, GPEN, BGN, POS);}

system("pause");

return 0;}

HPEN getPen(intiPEN_STYLE, intiPEN_SIZE, intiCOLORREF){

returnCreatePen(iPEN_STYLE, iPEN_SIZE, iCOLORREF);}

BOOL SetPoint(HDC hDC, HPEN hPen, COORD PNT){

EXTLOGPEN pINFO;

GetObject(hPen,sizeof(EXTLOGPEN),&pINFO);

SelectObject(hDC,hPen);

return Ellipse(

hDC,

PNT.X - pINFO.elpWidth,



PNT.Y + pINFO.elpWidth,

PNT.X + pINFO.elpWidth,

PNT.Y - pINFO.elpWidth);}

BOOL PlotLine(HDC hDC, HPEN hPen, COORD BGN, COORD END){

SelectObject(hDC,hPen);

MoveToEx(hDC,BGN.X,BGN.Y,NULL);

returnLineTo( hDC,END.X,END.Y);}

BOOL PlotRect(HDC hDC, HPEN hPen, COORD BGN, COORD END){

SelectObject(hDC,hPen);

return Rectangle(hDC,BGN.X, BGN.Y, END.X, END.Y);}

BOOL PlotCirc(HDC hDC, HPEN hPen, COORD BGN, COORD END){

SelectObject(hDC,hPen);

return Ellipse(hDC,BGN.X, BGN.Y, END.X, END.Y);}

COORD setCordScale(COORD POS, RECT pRECT){

if(POS.X == 0)

POS.X = 1;

if(POS.Y == 0)

POS.Y = 1;

intnROWS = 25;

intnCOLS = 80;

double CX = (pRECT.right - pRECT.left)/nCOLS;

double CY = (pRECT.bottom - pRECT.top)/nROWS;

POS.X *= CX;

POS.Y *= CY;

intxBORDER = GetSystemMetrics(SM_CXBORDER);

intyBORDER = GetSystemMetrics(SM_CYMENU);

intxDRAG = GetSystemMetrics(SM_CXDRAG);

intyDRAG = GetSystemMetrics(SM_CYDRAG);

POS.X += xBORDER + xDRAG;

POS.Y += yBORDER + yDRAG;



return POS;}
Download 71.45 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling