Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {program project1;}
- {var
- x,i:integer;
- function lustro(n:integer):string;
- begin
- repeat
- begin
- n:=n+chr(ord('0')+i);
- n:=n div x;
- i:=i+1;
- end;
- until (n mod x=0);
- begin
- writeln('Podaj liczbe: ');
- readln(n);
- writeln('Odwrotna liczba to: ', lustro(x));
- readln();
- end.}
- {var x:integer;
- function lustro(n:integer):string;
- var s:string;
- r:integer;
- begin
- s:='';
- while(n<>0) do
- begin
- r:=n mod 10;
- s:=s+chr(ord('0')+r);
- n:=n div 10;
- end;
- lustro:=s;
- end;
- begin
- writeln('Podaj liczbe: ');
- readln(x);
- writeln('Odwrotna liczba to: ', lustro(x));
- readln();
- end. }
- program project2;
- var
- plik:text;
- tekst:string;
- function suma(plik:string):integer;
- var
- a,i:integer;
- begin
- a:=0;
- reset(plik);
- for i:=0 to length(plik) do
- begin
- if(ord(plik[i])>=0) and (ord(plik[i])<=9) then
- begin
- a:=a+ord(plik[i]);
- end;
- end;
- suma:=a;
- end;
- begin
- assign(plik, 'liczby.txt');
- reset(plik);
- while(eof(plik)) do
- begin
- read(plik, liczba);
- tekst:=tekst+liczba;
- end;
- close(plik);
- writeln('Suma = ',suma(tekst));
- end.}
- function suma(plik:string):integer;
- var
- p:text;
- s:integer;
- z:char;
- begin
- s:=0;
- assign(p, plik);
- reset(p);
- while(not eof(p)) do
- begin
- read(p,z);
- if (z in ['0'..'9']) then
- s:=s+(ord(z)-ord('0'));
- end;
- close(p);
- suma:=s;
- end;
- begin
- writeln(suma('liczby.txt'));
- readln();
- end.
- program project3;
- function suma(plik:string):integer;
- var
- a,i:integer;
- plik:text;
- z:char;
- p1:file of integer;
- begin
- a:=0;
- assign(plik, plik);
- assign(p1, 'liczby.txt');
- rewrite(p1);
- reset(plik);
- while (not eof(plik)) do
- begin
- read(plik, liczba);
- if(liczba in ['0'..'9']) then
- a:=a+(ord(liczba) -ord('0');
- write(ord(liczba) - ord('0');
- end;
- close(plik);
- close(p1);
- writeln;
- writeln;
- suma:=a;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement