Показать сообщение отдельно

  #10  
Старый 04.02.2008, 21:08
LEE_ROY
Постоянный
Регистрация: 09.11.2006
Сообщений: 639
Провел на форуме:
1917742

Репутация: 541


По умолчанию

Цитата:
Сообщение от shefff  
нужна прога чтоб считала количество слов в предложении. срочно, плиззз
PHP код:
unit Unit1;

interface

uses
  Windows
MessagesSysUtilsVariantsClassesGraphicsControlsForms,
  
DialogsStdCtrlsXPMan;

type
  TForm1 
= class(TForm)
    
Edit1TEdit;
    
Button1TButton;
    
Label1TLabel;
    
XPMan1TXPMan;
    
procedure Button1Click(SenderTObject);
  private
    { Private 
declarations }
  public
    { Public 
declarations }
  
end;

var
  
Form1TForm1;

implementation

{$R *.dfm}

function 
CountWords(InputStringstring): integer;
var
  
aCharchar;
  
WordCountinteger;
  
IsWordboolean;
  
iinteger;
begin
  WordCount 
:= 0;
  
IsWord := False;
  for 
:= 0 to Length(InputString) do
  
begin
    aChar 
:= InputString[i];
    if (
aChar in [
      
'a''b''c''d''e''f''g''h''i''j''k''l''m''n''o''p''q''r''s',
        
't''u''v''w''x''y''z',
        
'A''B''C''D''E''F''G''H''I''J''K''L''M''N''O''P''Q''R''S',
        
'T''U''V''W''X''Y''Z',
        
'0''1''2''3''4''5''6''7''8''9''0''''''-'
        
]) then
    begin
      
if not IsWord then Inc(WordCount);
      
IsWord := True;
    
end
    
else if aChar '\' then IsWord := True
    else IsWord := False

  end;

  IsWord := False;
  Result := WordCount;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(CountWords(edit1.Text));
end;

end. 
EXE - http://dump.ru/files/o/o532484947/
 
Ответить с цитированием