Facebook
From Unique Ostrich, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 263
  1. program Zaliczenie;
  2. Uses StrUtils;
  3.  
  4. function samogloski(tekst:string):integer;
  5.  var i, liczba : integer;
  6.    begin
  7.      liczba:=0;
  8.      for i:=1 to length(tekst) do
  9.      begin
  10.    if (tekst[i]='a') or (tekst[i]='A') or (tekst[i]='e') or (tekst[i]='E') or
  11.    (tekst[i]='y') or (tekst[i]='Y') or (tekst[i]='i') or (tekst[i]='I') or
  12.    (tekst[i]='o') or (tekst[i]='O') or (tekst[i]='u') or (tekst[i]='U') then
  13.    liczba := liczba + 1;
  14.    end;
  15.      result := liczba;
  16.      end;
  17.  
  18. function duze_znaki(tekst:string):integer;
  19. var i, ilosc:integer;
  20.   begin
  21.   ilosc := 0;
  22.   for i:=1 to length(tekst) do
  23.     begin
  24.       if (ord(tekst[i])>=65) and (ord(tekst[i])<=90)  then
  25.       ilosc:=ilosc + 1;
  26.       end;
  27. result := ilosc;
  28. end;
  29.  
  30. function pierwsza_samogloska(tekst:string):integer;
  31. var i, ilosc: integer;
  32.   begin
  33.   ilosc:=0;
  34.  if (tekst[1]='a') or (tekst[1]='A') or (tekst[1]='e') or (tekst[1]='E') or
  35.    (tekst[1]='y') or (tekst[1]='Y') or (tekst[1]='i') or (tekst[1]='I') or
  36.    (tekst[1]='o') or (tekst[1]='O') or (tekst[1]='u') or (tekst[1]='U') then
  37.    ilosc:=ilosc + 1;
  38. for i:=1 to length(tekst) do begin
  39.  if (tekst[i]=',') or (tekst[i]='.') then begin
  40.   if (tekst[i+2]='a') or (tekst[i+2]='A') or
  41.    (tekst[i+2]='e') or (tekst[i+2]='E') or (tekst[i+2]='y') or (tekst[i+2]='Y') or
  42.    (tekst[i+2]='i') or (tekst[i+2]='I') or(tekst[i+2]='o') or (tekst[i+2]='O') or
  43.    (tekst[i+2]='u') or (tekst[i+2]='U') then ilosc:=ilosc+1;
  44.  end;
  45.  end;
  46.   result := ilosc;
  47.   end;
  48.  
  49. function liczby(tekst:string):integer;
  50. var i, ilosc, flaga:integer;
  51.   begin
  52.   ilosc:=0;
  53.   flaga:=1;
  54.   for i:=1 to length(tekst) do
  55.     begin
  56.       if ((tekst[i]>='0') and (tekst[i]<='9')) or
  57.         ((tekst[i-1]>='0') and (tekst[i-1]<='9') and (tekst[i]=',')) or
  58.         ((tekst[i-1]>='0') and (tekst[i-1]<='9') and (tekst[i]='.')) then
  59.         begin
  60.          if (flaga=1) then
  61.            begin
  62.         ilosc:=ilosc + 1;
  63.         flaga:=0;
  64.         end;
  65.         end
  66.       else flaga:=1;
  67.     end;
  68.     result:=ilosc;
  69.   end;
  70.  
  71. function zlicz_spojniki(tekst:string):integer;
  72. const spojniki:array[1..3] of string = (' a ',' lub ', ' i ');
  73. var ilosc, pozycja, pozycja_temp, i, licznik:integer;
  74.    begin
  75.    licznik:=1;
  76.    ilosc:=0;
  77.    pozycja:=1;
  78.    pozycja_temp:=1;
  79.    for i:=1 to 3 do
  80.      begin
  81.       while(licznik<=length(tekst)) do begin
  82.        pozycja:=PosEx(spojniki[i], tekst, licznik);
  83.        if(pozycja<>pozycja_temp) then begin
  84.         ilosc:=ilosc+1;
  85.         pozycja_temp:=pozycja;
  86.        end;
  87.              licznik:=licznik+length(spojniki[i])-1;
  88.        end;
  89.       pozycja:=1;
  90.       pozycja_temp:=-1;
  91.       licznik:=1;
  92.       end;
  93.    result:=ilosc;
  94.    end;
  95.  
  96.   var lancuch:string;
  97.      f:text;
  98.      licznik, d:integer;
  99. begin
  100.   licznik:=1;
  101.   assignfile(f, 'we.txt');
  102.   reset(f);
  103.   while not EoF(f) do
  104. begin
  105.   writeln('tekst nr.', licznik);
  106.   readln(f, lancuch);
  107.   writeln('ilosc samoglosek ', samogloski(lancuch));
  108.   writeln('ilosc zdan zaczynajacych sie od samogloski  ', pierwsza_samogloska(lancuch));
  109.   writeln('ilosc duzych znakow: ', duze_znaki(lancuch));
  110.   writeln('ilosc liczb: ', liczby(lancuch));
  111.   writeln('ilosc spojnikow: ', zlicz_spojniki(lancuch));
  112.   writeln('-------------------------------------------------');
  113.   licznik:=licznik+1;
  114. end;
  115.   closefile(f);
  116.   readln;
  117. end.