Yaratilgan sana


Download 197.96 Kb.
bet2/2
Sana04.11.2023
Hajmi197.96 Kb.
#1748125
TuriReferat
1   2
Bog'liq
Dastur kodi

Dastur natijasi – Xulosa qilib aytganda, oʻzbek adabiyoti tarixini oʻrganish uning shakllanishi va taraqqiyoti omillarini chuqur hamda atroflicha tasavvur qilish imkonini berishi bilan birga, hozirgi avlodlar tafakkurida milliy oʻzlikni anglash, gʻurur va iftixor tuygʻularini yuksaltirish, maʼnaviy olamlarini boyitishda mislsiz darajada katta ahamiyat kasb etadi. Mazkur toʻplamdan koʻzlangan maqsad esa, uni oʻrganayotganlarda Vatanga, milliy qadriyatlarga sadoqat tuygʻusini yuksaltirishdan iboratdir.
EHM tipi: IBM tipidagi shaxsiy kompyuterlar.
Dasturlash tili: C#, C++, Python
Operatsion tizim: Windows 2000 va undan yuqori.
Dastur hajmi: 74 Мб.
Dastur kodi
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1Click(TObject *Sender)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Label2Click(TObject *Sender)


{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn1Click(TObject *Sender)


{
}
//---------------------------------------------------------------------------
unit Unit1;

interface


uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,


Dialogs, StdCtrls, ExtCtrls, Grids, Buttons;

type
TForm1 = class(TForm)


OpenDialog1: TOpenDialog;
Panel1: TPanel;
Label1: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
s, ss, s1, s2: string;


f, f2: TextFile;
Form1: TForm1;
n, m: integer;
a, x, y: array of array of real;
b1: array of integer;
implementation

{$R *.dfm}


procedure k_mean(var k1, k2: integer);
var s1, s2: real;
i, j: integer;
begin
k1:=0; k2:=0;
for j:=1 to m do begin
y[1,j]:=0;
y[2,j]:=0;
end;
for i:=1 to n do begin
s1:=0;
s2:=0;
for j:=1 to m do begin
s1:=s1+sqr(x[1,j]-a[i,j]);
s2:=s2+sqr(x[2,j]-a[i,j]);
end;
s1:=sqrt(s1);
s2:=sqrt(s2);
if s1then begin
b1[i]:=1;
k1:=k1+1;
end
else begin
b1[i]:=2;
k2:=k2+1;
end;
for j:=1 to m do
y[b1[i],j]:=y[b1[i],j]+a[i,j];
end;
for j:=1 to m do begin
x[1,j]:=y[1,j]/k1;
x[2,j]:=y[2,j]/k2;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: integer;
begin
Label1.Visible:=True;

if not OpenDialog1.Execute() then


begin
ShowMessage('Fayl topilmadi');
StringGrid1.Visible:=True;
Exit;
end;

StringGrid1.Visible:=True;


s:=OpenDialog1.FileName;
ss:='';

while(pos('\',s)<>0) do


begin
ss:=ss+copy(s,1,pos('\',s));
delete (s,1,pos('\',s));
end;
s:=ss+'t_'+s;
AssignFile(f,OpenDialog1.FileName);
Reset(f);
readln(f,s1);
i:=0; j:=0;
while pos(';',s1)<>0 do
begin
s2:=copy(s1,1,pos(';',s1)-1);
delete (s1,1,pos(';',s1));
StringGrid1.Cells[j,i]:=s2;
j:=j+1;
end;
StringGrid1.Cells[j,i]:=s1;
m:=j;
//ShowMessage(IntToStr(m));
StringGrid1.ColCount:=m+1;

if not((StringGrid1.Cells[0,0] = 'ton') and (StringGrid1.Cells[m,0] <> 'sinf')) then


begin
Label1.Caption := 'Fayl formati mos kelmadi!';
CloseFile(f);
StringGrid1.Visible:=False;
exit;
end;
BitBtn2.Enabled:=True;
Label1.Visible:=False;
while not eof(f) do
begin
readln(f,s1);
i:=i+1;
j:=0;
while pos(';',s1)<>0 do
begin
s2:=copy(s1,1,pos(';',s1)-1);
delete (s1,1,pos(';',s1));
StringGrid1.Cells[j,i]:=s2;
j:=j+1;
end;
StringGrid1.Cells[j,i]:=s1;
end;
CloseFile(f);
n:=i;
StringGrid1.RowCount:=n+1;
//ShowMessage(IntToStr(n)+' '+IntToStr(m));
BitBtn1.Enabled:= False;
BitBtn2.Enabled:= True;
SetLength(a, n+1, m+1);
SetLength(b1, n+1);
SetLength(x, 3, m+1);
SetLength(y, 3, m+1);

if StringGrid1.Cells[1,0]='Nomi' then begin


for i:=1 to n do begin
for j:=2 to m do
if StringGrid1.Cells[j,i] <> '' then
a[i,j-1]:= StrToFloat(StringGrid1.Cells[j,i])
else a[i,j-1]:=0;
b1[i]:=0; end;
m := m-1;
end else
for i:=1 to n do begin
for j:=1 to m do
if StringGrid1.Cells[j,i] <> '' then
a[i,j]:=StrToFloat(StringGrid1.Cells[j,i])
else a[i,j]:=0;
b1[i]:=0; end;
end;

procedure TForm1.Button3Click(Sender: TObject);


begin
Close;
end;

procedure TForm1.Button2Click(Sender: TObject);


var
plan, t: boolean;
i, j, r1, r2, k1, k2, k11, k22: integer;

begin

StringGrid1.CleanupInstance;
StringGrid1.Visible:=false;
//showmessage(IntToStr(n)+' '+IntToStr(m));
m:=m-1;
randomize;
r1:=random(n-1)+1;
r2:=random(n-1)+1;
if r1=r2 then r2:=r2+1;
for j:=1 to m do begin
x[1,j]:=a[r1,j];
x[2,j]:=a[r2,j]; end;
b1[r1]:=1; b1[r2]:=2;
k1:=0; k2:=0; t:=true;
while t do begin
k11:=k1; k22:=k2;
k_mean(k1,k2);
//ShowMessage(IntToStr(k1)+' '+IntToStr(k2));
if (k11=k1)and(k22=k2) then t:=false;
end;
//ShowMessage(IntToStr(k1)+' '+IntToStr(k2));
if MessageDlg('Obyektlar soni: '+IntToStr(n)
+#13#10+'Birinchi sinf vakillari: '+IntToStr(k1)
+#13#10+'Ikkinchi sinf vakillari: '+IntToStr(k2)
+#13#10#13#10+'Natijani faylga saqlaysizmi?',
mtCustom, [ mbNo, mbYes] , 1) = mrYes then
begin
AssignFile(f,OpenDialog1.FileName);
Reset(f);
AssignFile(f2, s);
rewrite(f2);
readln(f,s1);
writeln(f2, s1, ';sinf');
i:=0;
while not eof(f) do begin
i:=i+1;
readln(f,s1);
writeln(f2,s1,';',b1[i]);
end;
CloseFile(f);
CloseFile(f2);
ShowMessage('Natija ' + s + ' da saqlandi!');
end;

end;
procedure TForm1.BitBtn3Click(Sender: TObject);


begin
ShowMessage(' Ushbu dastur obyektlarni sinflarga ajratishga '
+#13#10+ 'muljallangan bo`lib 2020 yilda '
+#13#10+ 'Qarshi davlat universiteti, '
+#13#10+ 'Fizika - matematika fakulteti, '
+#13#10+'Amaliy matematika kafedrasida '
+#13#10+ 'ishlab chiqildi. ');
end;
end.
procedure RotS;
label 1;
Var
i,j,iter,t1,al:integer;
c0,c1,s:real;
c: array of real;
//qiymatlarni staxastik aniqlash;
function staxastik():real;
Var
smin,smax:real;
i:integer;
Begin
smin:=c[1]; smax:=c[n];
for i:=2 to k[1] do
if c[i]for i:=k[1]+1 to n-1 do
if smaxstaxastik:=smin-smax;
End;

Begin
SetLength(c,n);


for i:=1 to n do
begin
s:=0;
for j:=1 to m-1 do
s:=s+a[i,j];
a[i,0]:=s;
c[i]:=s;
end;
// 0-iteratsiya;
c0:=staxastik();
iter:=0;
t1:=1;
al:=0;
// keyingi iteratsiyalar;
//pmatr(a);
while iter<10000 do
Begin
al:=al+1;
iter:=iter+1;

if al>m-1 then al:=1;


if a[0,al]<>0 then begin


for i:=1 to n do
c[i]:=a[i,0]+(-1)*2*a[i,al];
c1:=staxastik();
if c0begin
c0:=c1;
t1:=1;
a[0,al]:=-1*a[0,al];
for i:=1 to n do
begin
a[i,al]:=-1*a[i,al];
a[i,0]:=c[i];
end;
end
else t1:=t1+1;
end;
if t1>m-1 then goto 1;
end;
1:End;

//miqdoriy alomatlar hisobi;


function Wmax(c1:real):real;
var s1,s2,s3,s4:real;
i1,j1:integer;
u:array[1..2,1..2] of integer;
begin
//U larni hisoblash;
u[1,1]:=0;
u[1,2]:=0;
u[2,1]:=0;
u[2,2]:=0;
for i1:=1 to n do
begin
if (b1[i1]=1)and(a[i1,al]<=c1) then u[1,1]:=u[1,1]+1;
if (b1[i1]=1)and(a[i1,al]>c1) then u[1,2]:=u[1,2]+1;
if (b1[i1]=2)and(a[i1,al]<=c1) then u[2,1]:=u[2,1]+1;
if (b1[i1]=2)and(a[i1,al]>c1) then u[2,2]:=u[2,2]+1;
end;
//W ni hisoblash;
s1:=0; s2:=0; s3:=0;
for i1:=1 to 2 do
begin
s1:=s1+u[i1,1]*(u[i1,1]-1)+u[i1,2]*(u[i1,2]-1);
s2:=s2+abs(k[i1])*abs(k[i1]-1);
s4:=0;
for j1:=1 to 2 do
s4:=s4+u[j1,i1]*(abs(k[3-j1])-u[3-j1,i1]);
s3:=s3+s4; end;
Wmax:=(s1/s2)*(s3/(2*abs(k[1])*abs(k[2])));
End;

// Miqdoriy protsedura


Procedure miqdoriy (ti:integer);
var i,j,x: integer;
max,w,c0,c2,c1,p,t:real;

begin
// ShowMessage(IntToStr(ti)+' '+ IntToStr(m));


//saralash;


for i:=1 to n do
bd[i]:=a[i,al];

for i:=1 to n-1 do


for j:=i+1 to n do
if bd[i]begin
t:=bd[i];
bd[i]:=bd[j];
bd[j]:=t;
end;
cd[1]:=bd[1];
x:=1;
for i:=2 to n do
if cd[x]<>bd[i] then
begin
x:=x+1;
cd[x]:=bd[i];
end;

//Jadvalni to'ldirish;


max:=wmax(cd[2]);


c1:=cd[2];


for i:=3 to x-1 do
begin
p:=wmax(cd[i]);
if max
begin
c1:=cd[i];
max:=p;
end;
end;
c0:=cd[x];
c2:=cd[1];
a[0,al]:=ti;
w:=a[0,al]*max;
p:=c2-c0;
for i:=1 to n do
a[i,al]:=w*(a[i,al]-c1)/p;

R[al].k:=al;


R[al].t:=ti;
R[al].c0:=cd[x];
R[al].c1:=c1;
R[al].c2:=cd[1];
R[al].w:=max;

End;

//nominal alomatlar hisobi;
Procedure nominal;
const t1=4; t2=30;
Var
i,j,p1:integer;
s,lyam,v:real;
g:array[1..t1,0..t2]of integer;
p:array[0..t2]of integer;
l,d:array[0..t1]of integer;
begin
//Gradatsiyalar sonini hisoblash;
for i:=0 to t2 do
p[i]:=0;
for i:=1 to n do
p[round(a[i,al])]:=p[round(a[i,al])]+1;
p1:=0;
for j:=0 to t2 do
if p[j]>0 then p1:=p1+1;

//lyamdani hisoblash;


for i:=1 to t1 do
for j:=0 to t2 do
g[i,j] := 0;
for i:=1 to n do
g[b1[i],round(a[i,al])]:=g[b1[i],round(a[i,al])]+1;
s:=0;
for i:=0 to t2 do
s:=s+g[1,i]*g[2,i];
lyam:=1-s/(k[1]*k[2]);

//DD-vesni hisoblash


l[1]:=0; l[2]:=0;
d[1]:=0; d[2]:=0;
for i:=0 to t2 do begin
if g[1,i]>0 then l[1]:=l[1]+1;
if g[2,i]>0 then l[2]:=l[2]+1; end;
if p1>2 then begin
d[1]:=(k[1]-l[1]+1)*(k[1]-l[1]);
d[2]:=(k[2]-l[2]+1)*(k[2]-l[2]); end
else begin
d[1]:=k[1]*(k[1]-1);
d[2]:=k[2]*(k[2]-1) end;

// Bettani hisoblash;


s:=0;
if d[1]+d[2]<>0 then begin
for i:=0 to t2 do
s:=s+(g[1,i]*(g[1,i]-1)+g[2,i]*(g[2,i]-1));
s:=s/(d[1]+d[2]); end;
v:=lyam*s;
R[al].k:=al;
R[al].t:=0;
R[al].c0:=lyam;
R[al].c1:=d[1];
R[al].c2:=s;
R[al].w:=v;
// Myuni hisoblash;
for i:=1 to n do
a[i,al]:=v*(g[1,round(a[i,al])]/k[1]-g[2,round(a[i,al])]/k[2]);
End;
//sinfga tegishli obyektlar sonini hisoblash;
Procedure k1k2;
var i: integer;
begin
for i:=1 to n do
if(b1[i]=1) or (b1[i]=2) then
k[b1[i]]:=k[b1[i]]+1;
End;

//-------------------------------------------------------


procedure TForm1.Ochis1Click(Sender: TObject);
var s1,s2: string;
f: TextFile;
i,j: Integer;
ss:string;
begin
if not OpenDialog1.Execute() then
begin
ShowMessage('Fayl topilmadi');
StringGrid1.Visible:=True;
Exit;
end;
StringGrid1.Visible:=True;

s:=OpenDialog1.FileName;


ss:='';

while(pos('\',s)<>0) do


begin
ss:=ss+copy(s,1,pos('\',s));
delete (s,1,pos('\',s));
end;
s:=ss+'n_'+s;
AssignFile(f,OpenDialog1.FileName);
Reset(f);
readln(f,s1);
i:=0; j:=0;
while pos(';',s1)<>0 do
begin
s2:=copy(s1,1,pos(';',s1)-1);
delete (s1,1,pos(';',s1));
StringGrid1.Cells[j,i]:=s2;
j:=j+1;
end;
StringGrid1.Cells[j,i]:=s1;
m:=j;
//ShowMessage(IntToStr(m));
StringGrid1.ColCount:=m+1;

if not((StringGrid1.Cells[0,0] = 'tjf') and (StringGrid1.Cells[j,0] = '2')) then


begin
Label1.Caption := 'Fayl formati mos kelmadi!';
CloseFile(f);
StringGrid1.Visible:=False;
exit;
end;

while not eof(f) do


begin
readln(f,s1);
i:=i+1;
j:=0;
while pos(';',s1)<>0 do
begin
s2:=copy(s1,1,pos(';',s1)-1);
delete (s1,1,pos(';',s1));
StringGrid1.Cells[j,i]:=s2;
j:=j+1;
end;
StringGrid1.Cells[j,i]:=s1;
end;
CloseFile(f);
n:=i;

StringGrid1.RowCount:=n+1;


Ochis1.Enabled:=False;


Hisoblash1.Enabled:=True;
end;

procedure TForm1.Hisoblash1Click(Sender: TObject);


var
i,j:integer;
f:TextFile;
plan:boolean;
begin
Memo1.Clear;

Setlength(cs, m+1);


SetLength(bs, n+1);
SetLength(a, n+1, m+1);
SetLength(b1, n+1);
// AssignFile(f, 'temp.txt');
// Rewrite(f);
plan:=false;
bs[0]:=StringGrid1.Cells[0,1];
if not((StringGrid1.Cells[1,0]='0')
or (StringGrid1.Cells[1,0]='1')) then
begin

plan:=true;


for i:=2 to m-1 do


begin
cs[i-1]:= StringGrid1.Cells[i,1];
a[0, i-1] := StrToFloat(StringGrid1.Cells[i,0]);
end;
b1[0]:= StrToInt(StringGrid1.Cells[m, 0]);
for i:=2 to n do
begin
bs[i-1]:= StringGrid1.Cells[1, i];

for j:=2 to m-1 do


if StringGrid1.Cells[j,i] <> '' then
a[i-1,j-1] := StrToFloat(StringGrid1.Cells[j,i])
else a[i-1,j-1]:=0;

if(StringGrid1.Cells[m,i]<>'') then


b1[i-1]:= StrToInt(StringGrid1.Cells[m, i]);
end;

n := n-1;


m := m-1;
end else
begin
for i:=1 to m-1 do
begin
cs[i]:= StringGrid1.Cells[i,1];
a[0, i] := StrToFloat(StringGrid1.Cells[i,0]);
end;

b1[0]:= StrToInt(StringGrid1.Cells[m, 0]);


for i:=2 to n do
begin
bs[i-1]:= StringGrid1.Cells[1, i];

for j:=1 to m-1 do


if StringGrid1.Cells[j,i] <> '' then
a[i-1,j] := StrToFloat(StringGrid1.Cells[j,i])
else a[i-1,j]:=0;

if(StringGrid1.Cells[m,i]<>'') then


b1[i-1]:= StrToInt(StringGrid1.Cells[m, i]);
end;
n := n-1;
end;

StringGrid1.CleanupInstance;


StringGrid1.Visible:=false;
k[1] := 0; k[2] := 0;
k1k2;

if (k[1] = 0) or (k[2] = 0) or ((k[1]+k[2]<>n)) then begin


label1.Caption := 'oxirgi(sinf) ustunida xatolik';
exit;
end;

Setlength(rs, n+1); //sss


Setlength(R, n+1); //ssss
Setlength(bd, n+1); //ssss
Setlength(cd, n+1); //ssss

randomize;


for al:=1 to m-1 do


begin
//ShowMessage(floatToStr(a[0,al]));
if a[0,al]=0 then nominal
else
if odd(random(100)) then
miqdoriy(-1)
else
miqdoriy(1);
end;

//alomatlar hissasi;


for i:=1 to m-2 do
for j:=i+1 to m-1 do
if R[i].wbegin maxW:=R[i];
R[i]:=R[j];
R[j]:=maxW;
end;
AssignFile(f,s);
rewrite(f);
DecimalSeparator:=',';
Memo1.Visible:=true;
writeln(f, bs[0]+' masalasi uchun olingan natijalar:');

Memo1.Lines.Add(bs[0]+' masalasi uchun olingan natijalar:');


Memo1.Lines.Add('-');
Memo1.Lines.Add('Alomatlar hissasi:');

writeln(f,'Alomatlar hissasi:');


writeln(f);

writeln(f,'No', ';', 'Alomat',';', 'C0',';','C1',';','C2', ';', 'Alomat vazni');


Memo1.Lines.Add('No Alomat C0 C1 C2 Alomat vazni');
for i:=1 to m-1 do begin
writeln(f,i,';', cs[R[i].k],';',floattostr(R[i].c0),
';',floattostr(R[i].c1),';', floattostr(R[i].c2),
';', floattostr(R[i].w));

Memo1.Lines.Add(inttostr(i) + ' ' + cs[R[i].k]+' ' + floattostr(R[i].c0)+


' ' + floattostr(R[i].c1)+' '+ floattostr(R[i].c2)+
' '+ floattostr(R[i].w));
end;
RotS;
cmax:=a[1,0];
cmin:=a[1,0];
for i:=2 to n do
begin
if a[i,0]>cmax then cmax:=a[i,0];
if a[i,0]

for i:=1 to n do


begin
rs[i].t:=i;
rs[i].k:=b1[i];
rs[i].r:=(a[i,0]-cmin)/(cmax-cmin);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if rs[i].rbegin rm:=rs[i];
rs[i]:=rs[j];
rs[j]:=rm; end;

writeln(f);


Memo1.Lines.Add('-');
writeln(f,' R(s) jadvali:');
Memo1.Lines.Add(' R(s) jadvali:');
writeln(f);
Memo1.Lines.Add('-');
if plan then
begin
writeln(f,'No; Obyekt nomi; Sinfi; Bahosi');
Memo1.Lines.Add('No Obyekt nomi Sinfi Bahosi');
for i:=1 to n do
begin

writeln(f,i,';',bs[Rs[i].t],';',Rs[i].k,';',floattostr(Rs[i].r));


Memo1.Lines.Add(inttostr(i)+' '+bs[Rs[i].t]+' '+inttostr(Rs[i].k)+' '+floattostr(Rs[i].r));
end;
end else
begin
Memo1.Lines.Add('No Obyekt nomeri Sinfi Bahosi');
writeln(f,'No; Obyekt nomeri; Sinfi; Bahosi');
for i:=1 to n do
begin
writeln(f,i,';',Rs[i].t,';',Rs[i].k,';',floattostr(Rs[i].r));
Memo1.Lines.Add(inttostr(i)+' '+inttostr(Rs[i].t)+ ' '+inttostr(Rs[i].k)+' '+floattostr(Rs[i].r));
end;
end;

closeFile(f);


Hisoblash1.enabled:= False;
end;
procedure TForm1.Chiqish1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.Dasturhaqida1Click(Sender: TObject);


begin
ShowMessage(' Ushbu dastur umumlashgan baholarni hisoblashga '
+ 'muljallangan bo`lib 2020 yilda '
+ 'Qarshi davlat universiteti, '
+ 'Fizika - matematika fakulteti, '
+ 'Amaliy matematika kafedrasida '
+ 'ishlab chiqildi. ');
end;


end.

Download 197.96 Kb.

Do'stlaringiz bilan baham:
1   2




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