jaret holdem

jaret holdem

  • NA
  • 1
  • 2.3k

Need to make Pascal Program which read from file numb.txt numbers and save them in array?

Oct 24 2012 10:07 AM
I need to make Program which read from file numb.txt numbers and save them in array (numbers are not more than 500).

Need to make calculations and each answer write in other line. (All answers need to write in file ans.txt and show on screen:
1)In file first line write your name;
2) How much numbers are in file numb.txt;
3) arithmetic mean;
4)odd and even number sum;
5)In 1 line show 30 numbers;
6)Min and max number;
7)All number sum;
8)Search prime numbers;

I try to do something but ...
program file1;
uses crt;
var f,b:text;

min,max,s,prim,k,r:integer;
vid:real;
sum,sump,sumn:longint;
t:array [1..500] of integer;
begin
clrscr;
assign (f,'g:\numb.txt');
reset (f);
assign (b,'g:\ans.txt');
rewrite (b);
repeat
read (f);
until eof (f);
vid:=0;
min:=1001;
max:=0;


prim:=0;
sum:=0;
sump:=0;
sumn:=0;
writeln (b,Name');

for k:=1 to 20 do
begin
for s:=1 to 30 do

begin
read (f,t[s]);

write (t[s]);
sum:=sum+t[s];

writeln ;


if t[s] mod 2=1 then sumn:=sumn+t[s];
if t[s] mod 2=0 then sump:=sump+t[s];
if t[s] > max then max:= t[s];
if t[s] < min then min:=t[s];
end;
writeln;
end;
vid:=sum/s;

writeln ('There are numbers' ,s);
writeln ('arithmetic mean',vid);
writeln ('odd number sum',sump,'even number sum',sumn);
writeln ('Min number',min,'Max number ',max);

close (b);
close (f);
readln;

end.