Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > [ "Начинающим" ]
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

Ответ
 
Опции темы Поиск в этой теме Опции просмотра
  #1  
Старый 13.07.2009, 21:42
Аватар для pesi
pesi pesi вне форума
Активный
 
Регистрация: 12.09.2008
Сообщения: 275
Репутация: 43
По умолчанию

попробуй так, только тут подбор до 4 символов

Код:
function number1(const S:string):string;
var
i:integer;
str:string;
begin
 str := '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
 Result:='';
 for i:=1 to Length(str) do
  if str[i] = s  then
   begin
    Result:=str[i];
    exit;
   end;
end;

//111111111111111111111111111111111111111111111111111111111111111111111111111111

function number2(const S:string):string;
var
i1, i2:integer;
str:string;
bol:boolean;
begin
 bol:=false;
 str := '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
 Result:='';

 for i1:=1 to Length(str) do
  if str[i1] = s  then
   begin
    bol:=true;
    Result:=str[i1];
    exit;
   end;

if bol=false then
 begin
  for i1:=1 to Length(str) do
  for i2:=1 to Length(str) do
   if str[i1]+str[i2] = s  then
    begin
     Result:=str[i1]+str[i2];
     exit;
    end;
end;
end;

//2222222222222222222222222222222222222222222222222222222222222222222222222222222

function number3(const S:string):string;
var
i1, i2, i3, u :integer;
str :string;
bol:boolean;
begin
 bol:=false;
 str := '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
 Result:='';
 u:=Length(str);

for i1:=1 to u do
  if str[i1] = s  then
   begin
    bol:=true;
    Result:=str[i1];
    exit;
   end;
if bol=false then
 begin
  for i1:=1 to u do
  for i2:=1 to u do
   if str[i1]+str[i2] = s  then
    begin
     bol:=true;
     Result:=str[i1]+str[i2];
     exit;
    end;
end;

if bol=false then
 begin
 for i1:=1 to u do
  for i2:=1 to u do
  for i3:=1 to u do
  begin
   if str[i1]+str[i2]+str[i3] = s  then
    begin
     Result:=str[i1]+str[i2]+str[i3];
     exit;
    end;
  end;
end;
end;

//33333333333333333333333333333333333333333333333333333333333333333333333333333333333333

function number4(const S:string):string;
var
i1, i2, i3, i4, u :integer;
str :string;
bol:boolean;
begin
 bol:=false;
 str := '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
 Result:='';
 u:=Length(str);

for i1:=1 to u do
  if str[i1] = s  then
   begin
    bol:=true;
    Result:=str[i1];
    exit;
   end;

if bol=false then
 begin
  for i1:=1 to u do
  for i2:=1 to u do
   if str[i1]+str[i2] = s  then
    begin
     bol:=true;
     Result:=str[i1]+str[i2];
     exit;
    end;
end;

if bol=false then
 begin
 for i1:=1 to u do
  for i2:=1 to u do
  for i3:=1 to u do
  begin
   if str[i1]+str[i2]+str[i3] = s  then
    begin
     bol:=true;
     Result:=str[i1]+str[i2]+str[i3];
     exit;
    end;
  end;
end;

if bol=false then
 begin
 for i1:=1 to u do
  for i2:=1 to u do
  for i3:=1 to u do
   for i4:=1 to u do
  begin
   if str[i1]+str[i2]+str[i3]+str[i4] = s  then
    begin
     Result:=str[i1]+str[i2]+str[i3]+str[i4];
     exit;
    end;
  end;
end;
end;

//4444444444444444444444444444444444444444444444444444444444444444444444444444444

procedure TForm1.Button1Click(Sender: TObject);
begin
edit3.Clear;

 if strtoint(edit2.Text)= 1 then
  edit3.Text:=number1(edit1.Text) else

 if strtoint(edit2.Text)= 2 then
  edit3.Text:=number2(edit1.Text) else

 if strtoint(edit2.Text)= 3 then
  edit3.Text:=number3(edit1.Text) else

 if strtoint(edit2.Text)= 4 then
  edit3.Text:=number4(edit1.Text)

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


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра
Комбинированный вид Комбинированный вид

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 06:49.


 

Сайт

Форум

FAQ

Соглашения

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2026