1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130:
| unit Dreck;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls;
type TForm1 = class(TForm) Label4: TLabel; Label7: TLabel; Button1: TButton; StringGrid1: TStringGrid; OpenDialog1: TOpenDialog; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); var j:integer; begin for j:=1 to StringGrid1.RowCount do begin StringGrid1.Cells[0,j]:=IntToStr(j); end;
for j:=1 to StringGrid1.RowCount do begin StringGrid1.Cells[1,j]:=IntToStr(0); end;
StringGrid1.Cells[0,0]:='Kandidat'; StringGrid1.Cells[1,0]:='Stimmen absolut'; StringGrid1.Cells[2,0]:='Stimmen relativ'; end;
procedure TForm1.Button1Click(Sender: TObject); var textdatei:textfile; zeile:string; i,j,kan,anz,u,z,k:integer; a: array[1..10] of real; rolloe:real; begin if OpenDialog1.Execute then begin AssignFile(textdatei,opendialog1.filename); reset(textdatei); anz:=0; repeat anz:=anz+1; readln(textdatei,zeile); kan:=StrToInt(copy(zeile,11,1)); if kan=1 then begin if length(zeile)=12 then
StringGrid1.cells[1,10]:=IntToStr(StrToInt(StringGrid1.Cells[1,10])+1) else StringGrid1.Cells[1,1]:=IntToStr(StrToInt(StringGrid1.Cells[1,1])+1); end; for i:=2 to 9 do begin if StrToInt(StringGrid1.Cells[0,i])=kan then StringGrid1.Cells[1,i]:=IntToStr(StrToInt(StringGrid1.Cells[1,i])+1); end; until EOF(textdatei);
for k:=1 to 10 do a[k]:=strtoint(stringgrid1.Cells[1,k]);
label7.Caption:=inttostr(anz); for i:=1 to stringgrid1.RowCount do stringgrid1.Cells[2,i]:=floattostrf(100*strtoint(stringgrid1.cells[1,i])/anz,fffixed,7,2);
for u:=1 to 10 do begin for z:=1 to 10 do begin if a[u]>a[z] then begin rolloe:=a[u] ; a[u]:=a[z]; a[z]:=rolloe; end; end; for j:=1 to 10 do begin if stringgrid1.Cells[1,j]=floattostr(a[1]) then begin edit1.Text:=stringgrid1.Cells[0,j]; edit1.Width:=strtoint(stringgrid1.cells[2,j]); end;
if stringgrid1.Cells[1,j]=floattostr(a[2]) then begin edit2.Text:=stringgrid1.Cells[0,j]; edit2.Width:=strtoint(stringgrid1.cells[2,j]); end;
if stringgrid1.Cells[1,j]=floattostr(a[3]) then begin edit3.Text:=stringgrid1.Cells[0,j]; edit3.Width:=strtoint(stringgrid1.cells[2,j]);
end; end;
end; end; end;
end. |