Merhaba arkadaşlar bu örnekde 0 la 100 arası ögrenci ve 1 le 10 arası ders için random notu girdirip bununları analiz edicez.umarım faydalı olur.
Kod:
uses crt;
var
i,j:byte;
dizi:array[1..100,1..10] of integer;
ogrsay,derssay:byte;
ogrno,dersno:byte;
sonuc:byte;
str1:byte;
procedure ogrgir(ogrs,derss:byte);
begin
for i:=1 to ogrs do
begin
for j:=1 to derss do
begin
dizi[i,j]:=random(100);
end;
end;
end;
function dort(dersno:byte):integer;
begin
for i:=1 to ogrsay do
begin
sonuc:=sonuc+dizi[i,dersno];
end;
dort:=trunc(sonuc/ogrsay);
end;
function ogrort(ogrno:byte):integer;
begin
for i:=1 to derssay do
begin
sonuc:=sonuc+dizi[ogrno,i];
end;
ogrort:=trunc(sonuc/derssay);
end;
function tumort:integer;
begin
sonuc:=0;
for i:=1 to ogrsay do
begin
for j:=1 to derssay do
begin
sonuc:=sonuc+dizi[i,j]
end;
end;
tumort:=trunc(sonuc/(derssay*ogrsay));
end;
begin
clrscr;
writeln('kac ogrenci olacak ?');
readln(ogrsay);
writeln('kac ders olacak ?');
readln(derssay);
ogrgir(ogrsay,derssay);
str1:=1;
while (str1<>0) do
begin
writeln('ders ortalamasi gormek icin 1 e basin');
writeln('ogrenci ortalamasi gormek icin 2 e basin');
writeln('tumderslerin ortalamasi gormek icin 3 e basin');
readln(str1);
case str1 of
1:begin writeln('ders no gir :');readln(dersno); sonuc:=dort(dersno); writeln(dersno,'. dersin ortalaması :',sonuc); end;
2:begin writeln('ogr no gir :');readln(ogrno); sonuc:=ogrort(ogrno); writeln(ogrno,'. ogrencinin ortalaması :',sonuc); end;
3:begin sonuc:=tumort; writeln('tum derslerin ortalamasi :',sonuc); end;
end;
end;
readln;
end.