Parašė t0mas· 2010 Sau. 13 19:01:36
#8
Cia keli paprasti pascalio uzdavinukai. Gali dasikurt ir dadet while cikla. vis kas nors :)
//duotas intervalas nuo n iki m
//parasyti programa kuri surastu kiek skaiciu kurie turi lygiai k dalikliu.
program programa;
var m,n,k,d,i,j,sk :integer;
begin
WriteLn('Iveskite N,M skaicius:');
Readln(n,m);
Writeln('iveskite k skaiciu:');
Readln(k);
sk:=1;
for i:=n to m do
begin
d:=0;
for j:=1 to i do
if i mod j=0 then d:=d+1;
if k=d then begin
writeln( i);
sk:=sk+1;
end;
end;
writeln('kiekis ', sk);
Readln;
end.
-----------------------------
program programa;
var a, b,s,i,s1 :integer;
begin
WriteLn('Iveskite Skaicius a,b:');
Readln(a,b);
S:=0;
S1:=1;
for i:=a to b do
if i mod 2=0 then s:=s+i
else s1:=s1*i;
Writeln('Suma:', s);
Writeln('Sandauga:',s1);
Readln;
end.
--------------------------------
Cia susikursi dar tekstini failiuka
program programa;
var s,sk,n:integer;
f,g :text;
begin
assign(f,'failas.txt');reset(f);
assign(g,'rez.txt');rewrite(g);
n:=0;
while not eof(f) do
begin
n:=n+1;
s:=0;
while not eoln(f) do
begin
read(f,sk);
s:=s+sk;
end;
Readln(f);
WriteLn(g,n, 'Suma:', s);
end;
Close(f);
Close(g);
Readln;
end.