Показать сообщение отдельно
  #8  
Старый 20.12.2007, 08:13
Rosenkrantz Rosenkrantz вне форума
Активный
 
Регистрация: 04.12.2007
Адрес: Москва
Сообщения: 234
Версия Delphi: Delphi 7
Репутация: 40
По умолчанию

Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function  CountConsonants(S: String): LongInt;
const
  ConsonantChars: Set of Char =
    ['b','c','d','f','g','h','k','l','m','n','p','r','s','t','v','z','x'];
var
  L, i: LongInt;
begin
  L := Length(S);
  S := AnsiLowerCase(S);
  Result := 0;
  for i := 1 to L do
    if S[i] in ConsonantChars then
      Result := Result + 1; 
end;

function  ReverseStr(const S: String): String;
var
  L, i: Integer;
begin
  L := Length(S);
  Result := '';
  for i := 1 to L do
    Result := Result + S[L - i + 1];
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  N: LongInt;
  S: String;
begin
  N := CountConsonants(Edit1.Text);
  S := ReverseStr(Edit1.Text);

  Edit2.Text := Edit1.Text;
  while (N > 0) do begin
    Edit2.Text := Edit2.Text + S;
    N := N - 1;
  end;
end;

end.
Ответить с цитированием