Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 31-10-2015
diego21x diego21x is offline
Registrado
NULL
 
Registrado: oct 2015
Posts: 3
Poder: 0
diego21x Va por buen camino
ayuda con busqueda de palabra en una matriz

me podrian ayudar a buscar una palabra en una matriz ya echa
Código:
unit fvector;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  Grids, ExtCtrls, uvector;






type

  { TForm1 }

  TForm1 = class(TForm)
    Bcrear: TButton;
    Bsetdim: TButton;
    Bgetdim: TButton;
    Bsetelem: TButton;
    Bgetelem: TButton;
    Bsalir: TButton;
    Button1: TButton;
    ponerletras: TButton;
    Notebook1: TNotebook;
    Titulo: TLabel;
    ele: TStringGrid;
    procedure BcrearClick(Sender: TObject);
    procedure BgetdimClick(Sender: TObject);
    procedure BsetdimClick(Sender: TObject);
    procedure BsetelemClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure ponerletrasClick(Sender: TObject);
    procedure DrawGrid1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Notebook1ChangeBounds(Sender: TObject);
  private
    { private declarations }
    V:Vector;
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.BcrearClick(Sender: TObject);
begin
  v:=Vector.Crear();
  ele.ColCount:=13;
  ele.RowCount:=13;
  ShowMessage('Sopa de letras Creada...!!!');





end;

procedure TForm1.BgetdimClick(Sender: TObject);
begin
//  ShowMessage('La dimension es : '+IntToStr(v.getDim()));
end;

procedure TForm1.BsetdimClick(Sender: TObject);
var
  s:string;
  n:integer;
begin
  s:=InputBox('Sopa de letras','Dimension :','0');
  n:=StrToInt(s);
 // v.setDim(n);
 v.set_fila(n);
 v.set_col(n);
  //v.setDim(StrToInt(InputBox('Vector','Dimension :','0')));
  ele.ColCount:=v.get_col();
  ele.RowCount:=v.get_fila();
  //ele.FilaCount:=v.get.fila();
  //ele.
  //v.setElem(1,d);
end;

procedure TForm1.BsetelemClick(Sender: TObject);
var
  pos,pos2, elem :integer;

  elem1: string;
  elem2:string;
begin
  pos:=StrToInt(InputBox('Sopa de letras','Columna :','0'));
  ///elem1:=InputBox('Sopa de letraS','Elemento :','0');
    pos2:=StrToInt(InputBox('Sopa de letras','Fila :','0'));
  elem1:=InputBox('Sopa de LeTRAS','Elemento :','0');

  //elem:=StrToInt(elem1);

  //v.setElem(pos,elem1);


  //ele.Cells[pos-1,0]:=IntToStr(elem1);
  ele.Cells[pos-1,pos2-1]:=(elem1);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
   i:integer;
begin






end;

procedure TForm1.ponerletrasClick(Sender: TObject);
begin
  ele.Cells[0,0]:='e'; ele.Cells[1,0]:='a';ele.Cells[2,0]:='m'; ele.Cells[3,0]:='a'; ele.Cells[4,0]:='a'; ele.Cells[5,0]:='a';ele.Cells[6,0]:='m'; ele.Cells[7,0]:='a';ele.Cells[8,0]:='n'; ele.Cells[9,0]:='a';ele.Cells[10,0]:='x'; ele.Cells[11,0]:='z';ele.Cells[12,0]:='f';
  ele.Cells[0,1]:='n'; ele.Cells[1,1]:='b';ele.Cells[2,1]:='a'; ele.Cells[3,1]:='a'; ele.Cells[4,1]:='l'; ele.Cells[5,1]:='a';ele.Cells[6,1]:='a'; ele.Cells[7,1]:='g';ele.Cells[8,1]:='a'; ele.Cells[9,1]:='ñ';ele.Cells[10,1]:='a'; ele.Cells[11,1]:='a';ele.Cells[12,1]:='a';
  ele.Cells[0,2]:='e'; ele.Cells[1,2]:='o';ele.Cells[2,2]:='r'; ele.Cells[3,2]:='a'; ele.Cells[4,2]:='i'; ele.Cells[5,2]:='a';ele.Cells[6,2]:='y'; ele.Cells[7,2]:='a';ele.Cells[8,2]:='j'; ele.Cells[9,2]:='a';ele.Cells[10,2]:='a'; ele.Cells[11,2]:='a';ele.Cells[12,2]:='a';
  ele.Cells[0,3]:='r'; ele.Cells[1,3]:='f';ele.Cells[2,3]:='z'; ele.Cells[3,3]:='a'; ele.Cells[4,3]:='r'; ele.Cells[5,3]:='a';ele.Cells[6,3]:='o'; ele.Cells[7,3]:='j';ele.Cells[8,3]:='u'; ele.Cells[9,3]:='n';ele.Cells[10,3]:='i'; ele.Cells[11,3]:='o';ele.Cells[12,3]:='g';
  ele.Cells[0,4]:='a'; ele.Cells[1,4]:='g';ele.Cells[2,4]:='o'; ele.Cells[3,4]:='a'; ele.Cells[4,4]:='b'; ele.Cells[5,4]:='a';ele.Cells[6,4]:='a'; ele.Cells[7,4]:='a';ele.Cells[8,4]:='l'; ele.Cells[9,4]:='a';ele.Cells[10,4]:='a'; ele.Cells[11,4]:='a';ele.Cells[12,4]:='a';
  ele.Cells[0,5]:='o'; ele.Cells[1,5]:='o';ele.Cells[2,5]:='a'; ele.Cells[3,5]:='a'; ele.Cells[4,5]:='a'; ele.Cells[5,5]:='a';ele.Cells[6,5]:='a'; ele.Cells[7,5]:='g';ele.Cells[8,5]:='i'; ele.Cells[9,5]:='a';ele.Cells[10,5]:='a'; ele.Cells[11,5]:='a';ele.Cells[12,5]:='a';
  ele.Cells[0,6]:='f'; ele.Cells[1,6]:='o';ele.Cells[2,6]:='a'; ele.Cells[3,6]:='a'; ele.Cells[4,6]:='a'; ele.Cells[5,6]:='a';ele.Cells[6,6]:='f'; ele.Cells[7,6]:='o';ele.Cells[8,6]:='o'; ele.Cells[9,6]:='f';ele.Cells[10,6]:='a'; ele.Cells[11,6]:='a';ele.Cells[12,6]:='h';
  ele.Cells[0,7]:='g'; ele.Cells[1,7]:='e';ele.Cells[2,7]:='a'; ele.Cells[3,7]:='a'; ele.Cells[4,7]:='a'; ele.Cells[5,7]:='a';ele.Cells[6,7]:='g'; ele.Cells[7,7]:='s';ele.Cells[8,7]:='a'; ele.Cells[9,7]:='a';ele.Cells[10,7]:='a'; ele.Cells[11,7]:='a';ele.Cells[12,7]:='a';
  ele.Cells[0,8]:='m'; ele.Cells[1,8]:='o';ele.Cells[2,8]:='b'; ele.Cells[3,8]:='a'; ele.Cells[4,8]:='a'; ele.Cells[5,8]:='a';ele.Cells[6,8]:='a'; ele.Cells[7,8]:='t';ele.Cells[8,8]:='a'; ele.Cells[9,8]:='a';ele.Cells[10,8]:='a'; ele.Cells[11,8]:='a';ele.Cells[12,8]:='a';
  ele.Cells[0,9]:='q'; ele.Cells[1,9]:='o';ele.Cells[2,9]:='a'; ele.Cells[3,9]:='r'; ele.Cells[4,9]:='a'; ele.Cells[5,9]:='a';ele.Cells[6,9]:='m'; ele.Cells[7,9]:='o';ele.Cells[8,9]:='o'; ele.Cells[9,9]:='a';ele.Cells[10,9]:='a'; ele.Cells[11,9]:='a';ele.Cells[12,9]:='k';
  ele.Cells[0,10]:='s';ele.Cells[1,10]:='o';ele.Cells[2,10]:='a';ele.Cells[3,10]:='a'; ele.Cells[4,10]:='e'; ele.Cells[5,10]:='a';ele.Cells[6,10]:='a'; ele.Cells[7,10]:='a';ele.Cells[8,10]:='q'; ele.Cells[9,10]:='v';ele.Cells[10,10]:='u'; ele.Cells[11,10]:='a';ele.Cells[12,10]:='a';
  ele.Cells[0,11]:='d';ele.Cells[1,11]:='o';ele.Cells[2,11]:='a';ele.Cells[3,11]:='a'; ele.Cells[4,11]:='a'; ele.Cells[5,11]:='r';ele.Cells[6,11]:='a'; ele.Cells[7,11]:='a';ele.Cells[8,11]:='a'; ele.Cells[9,11]:='a';ele.Cells[10,11]:='a'; ele.Cells[11,11]:='a';ele.Cells[12,11]:='b';
  ele.Cells[0,12]:='m';ele.Cells[1,12]:='o';ele.Cells[2,12]:='a';ele.Cells[3,12]:='a'; ele.Cells[4,12]:='a'; ele.Cells[5,12]:='a';ele.Cells[6,12]:='o'; ele.Cells[7,12]:='a';ele.Cells[8,12]:='w'; ele.Cells[9,12]:='a';ele.Cells[10,12]:='s'; ele.Cells[11,12]:='e';ele.Cells[12,12]:='a';


end;

procedure TForm1.DrawGrid1Click(Sender: TObject);
begin

end;

procedure TForm1.FormCreate(Sender: TObject);
begin

end;

procedure TForm1.Notebook1ChangeBounds(Sender: TObject);
begin

end;

end.
y este el constructor
Código:
unit uvector;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Dialogs;
Const
  MAX_E=1000;
  MAX_F=1000;
  MAX_C=1000;
type
  Vector=Class
    private
      //elem:array[1..MAX_E]of string;
       elem:array[1..MAX_F, 1..MAX_C] of string;
      dim:integer;
      cant:Integer;
      nfils, ncols:integer;
    public
      constructor crear();
     // procedure setDim(num:integer);
     // function  getDim():integer;
     // procedure setElem(pos:integer;ele:string);
     // function  getElem(pos:integer):string;


        procedure set_ele(f,c:integer;ele:string);
      function get_ele(f,c:integer):string;
      procedure set_fila(fils:integer);
      function get_fila():integer;
      procedure set_col(cols:integer);
      function get_col():integer;
      //  function busquedarecto():integer;
      //function Pos( Substr: string; S: string ): Integer;


 end;

implementation
//constructor Vector.crear();
//var
 // i:integer;
//begin
 // i:=1;
 // while(i<=MAX_E)do
 // begin
 //   elem[i]:=' ';
  //  i:=i+1;
  //end;
 // dim:=0;
//end;


    constructor Vector.Crear();
var
 f,c:integer;
begin
  nfils:=0;
  ncols:=0;
  cant:=nfils*ncols;
  for f:=1 to MAX_F-1 do
     begin
       for c:=1 to MAX_C-1 do
          begin
             elem[f,c]:=' ';
          end;
     end;
end;






//procedure Vector.setDim(num:integer);
//begin
 // if(num>=0) AND (num<=MAX_E)then
   //  dim:=num
 // else
   // ShowMessage('Vector::setDim:Fuera de Rango');
//end;
//function  Vector.getDim():integer;
//begin
//  result := dim;
//end;
//procedure Vector.setElem(pos:integer;ele:string);
//begin
 // if(pos>0) AND (pos<=dim)then
  //   elem[pos]:=ele
 // else
  //   ShowMessage('Vector::SetElem:Fuera de Rango...');
//end;
//function  Vector.getElem(pos:integer):string;
//begin
//  if(pos>0) AND (pos<=dim)then
 //    result:=elem[pos]
 // else
 //    result:=' ';
//end;












         procedure Vector.set_ele(f, c:integer; ele: string);
begin
   if ((f>0) and (f<=nfils))then
     begin
       if (c>0) and (c<=ncols) then
          begin
            elem[f,c]:=' ';
          end
          else
          begin
            showmessage('Col fuera de rango');
          end;
     end
     else
       showmessage('fila fuera de rango');
end;

function Vector.get_ele(f, c: integer): string;
begin
   if (f>0)and(f<=nfils)then
     begin
       if (c>0)and(c<=ncols)then
         begin
           result:=elem[f,c];
         end
         else
         begin
          result:='fuera de rango ';
         end;
     end
     else
     begin
       result:='fuera de rango ';
     end;
end;
procedure Vector.set_fila(fils:integer);
begin
   if ((fils>=0)and(fils<=MAX_F))then
     begin
       nfils:=fils;
     end
     else
     begin
       showmessage('fuera de rango');
     end;
end;

function Vector.get_fila():integer;
begin
  result:=nfils;
end;
procedure Vector.set_col(cols: integer);
begin
   if (cols>=0)and(cols<=MAX_C)then
      ncols:=cols
else
  showmessage('fuera de rango');
end;

function Vector.get_col():integer;
begin
    result:=ncols;
end;





end.
se los agradezco de antemano
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Ayuda con una busqueda servicomp Conexión con bases de datos 6 17-11-2009 16:02:47
Ayuda en busqueda con SQL! rod203 SQL 3 28-04-2008 20:25:30
Leer fichero texto palabra por palabra... Lester Varios 2 03-04-2007 15:28:27
Leer palabra por palabra en Word solecito Servers 0 12-03-2007 20:58:13


La franja horaria es GMT +2. Ahora son las 09:03:30.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi