Sunushi

9.4, Występowanie liczby

Oct 26th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.82 KB | None | 0 0
  1. uses crt;
  2. var
  3.         a:char;
  4.         b:string;
  5.         c, d, ilosc:byte;
  6. begin
  7.         clrscr;
  8.         writeln('Program podaje ile razy wystapila pierwsza cyfra');
  9.         writeln('Aby zsumowac ilosc wpisz 0');
  10.         writeln;
  11.         write('Podaj ciag cyfr: ');
  12.         repeat
  13.                 a:=readkey;
  14.                 c:=byte(a);
  15.                 if (c>=48) and (c<=57) then
  16.                         begin
  17.                                 b:=b+a;
  18.                                 write(a);
  19.                                 d:=d+1;
  20.                                 if b[d] = b[1] then
  21.                                         ilosc:=ilosc+1;
  22.                         end;
  23.         until byte(b[length(b)]) = 48;
  24.         writeln;
  25.         writeln('Liczba ', b[1], ' pojawila sie ', ilosc,' razy');
  26.         readln;
  27. end.
Advertisement
Add Comment
Please, Sign In to add comment