Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 28-05-2015
anonymous anonymous is offline
Miembro
NULL
 
Registrado: may 2015
Posts: 23
Poder: 0
anonymous Va por buen camino
Cool Sumar los números asignados a una palabra

Buenas .. Me pidieron un trabajo donde por medio de el click de un button Ingresando el usuario un Nombre y Apellido ( DIEGO ARMANDO MARADONA ) Cada letra tiene su valor ya la carge con un contador hize la suma de las palabras pero no puedo descomponerlas , es decir no se como hacer para sumar los numeros de cada palabra entre si ..
Imágenes Adjuntas
Tipo de Archivo: jpg ajkj.jpg (20,3 KB, 18 visitas)
Responder Con Cita
  #2  
Antiguo 28-05-2015
anonymous anonymous is offline
Miembro
NULL
 
Registrado: may 2015
Posts: 23
Poder: 0
anonymous Va por buen camino
ESTE ES MI CODIGO POR LAS DUDAS NO SE SI ESTA ALGO BIEN O MAL
Código Delphi [-]
unit JEBUS;

interface

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

type
  TForm3 = class(TForm)
    BitBtn1: TBitBtn;
    Edit1: TEdit;
    Memo1: TMemo;
    Label1: TLabel;
    EdNom: TEdit;
    Label2: TLabel;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.BitBtn1Click(Sender: TObject);
Var i, cant ,cant1,cont,cont1,suma,suma1,resultado,sumav,sumac: Integer;
    nom, linea,linea1,linea2,linea3,linea4: string;
begin
   Memo1.Visible:=true;
   nom := EdNom.Text;
   linea := '';
   cant := 0;
   for i:=1 to length(nom) do
      if nom[i] in ['A','E','I','O','U','a','e','i','o','u'] then begin
         linea := linea + nom[i] +' ';
         cant := cant + 1;
      end;
      case  nom [i] of
      'A':cont:=1;
      'E':cont:=5;
      'I':cont:=9;
      'O':cont:=6;
      'U':cont:=3;
      end;

   Memo1.clear;
   Memo1.Lines.add('Su nombre contiene las vocales');
   Memo1.Lines.Add(linea);
   Memo1.Lines.Add('Total de vocales= '+ IntToStr(Cant));

   linea := '';
   cont1:= 0;
   for i := 1 to length (nom) do
   if nom [i] in ['B','C','D','F','G','H','J','K','L','M','Ñ','O','P','Q','R','S','T','V','W','X','Y','Z','b','c','d',  'f','g','h','j','k','l','m','n','ñ','p','q','r','s','t','v','w','x','y','z'] then
   begin
     linea1 := linea1 + nom[i] +' ';
         cant1 := cant1 + 1;
   case nom [i]  of
   'J','S':cont1:= 1;
   'B','K','T':cont1:= 2;
    'C','L':cont1:=3;
     'D','M','V':cont1:= 4;
      'N','W':cont1:=5;
       'F','X':cont1:=6;
        'G','P','Y':cont1:=7;
         'H','Q','Z':cont1:=8;
          'R':cont1:=9;
   end;
     end;
     linea4:=linea4+inttostr(cont)+' ';
     linea3:=linea3+nom[i]+' ';
     cant1:=cant1+1;

   Memo1.Lines.add('-------------------------------- ');
   Memo1.Lines.add('Cantidad de Consonantes');
   Memo1.Lines.Add(linea1);
    Memo1.Lines.Add('Total de Consonantes= '+ IntToStr(Cant1));

  linea := '';
   cant := 0;
   for i:=1 to length(nom) do
   begin
      if nom[i] in ['A','E','I','O','U','a','e','i','o','u'] then
       begin
         linea := linea + nom[i] +' ';
         cant := cant + 1;


   begin

   if nom [i] in ['A'] then
      sumav:=sumav+1;
    if nom [i] in ['E'] then
      sumav:=sumav+5;
     if nom [i] in ['I'] then
        sumav:=sumav+9;
        if nom [i] in ['O'] then
            sumav:=sumav+6;
          if nom [i] in ['U'] then
               sumav:=sumav+3;


   end;
       end;
   end;


   Memo1.Lines.add('-------------------------------- ');
   Memo1.Lines.Add('ESENCIA (lo que usted Quiere)');
   Memo1.Lines.Add(linea);
   Memo1.Lines.Add(inttostr(sumav));

   Memo1.Lines.add('-------------------------------- ');
   Memo1.Lines.Add('IMAGEN (como lo ven los demas)');
   Memo1.Lines.Add(linea);
   Memo1.Lines.Add(inttostr(cont1));

end;

end.

Última edición por nlsgarcia fecha: 28-05-2015 a las 22:14:51. Razón: Sintaxis Delphi
Responder Con Cita
  #3  
Antiguo 28-05-2015
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
anonymous,

¡Bienvenido al Club Delphi!

Nelson
Responder Con Cita
  #4  
Antiguo 28-05-2015
anonymous anonymous is offline
Miembro
NULL
 
Registrado: may 2015
Posts: 23
Poder: 0
anonymous Va por buen camino
Cita:
Empezado por nlsgarcia Ver Mensaje
anonymous,

¡Bienvenido al Club Delphi!

Nelson
GRACIASSS !
Responder Con Cita
  #5  
Antiguo 29-05-2015
aposi aposi is offline
Miembro
 
Registrado: dic 2006
Posts: 146
Poder: 18
aposi Va por buen camino
Hola,
vamos a centrarnos en el primer for:

tu tienes

Código Delphi [-]
Memo1.Visible:=true;
nom := EdNom.Text;
linea := '';
cant := 0;
for i:=1 to length(nom) do begin // te falta el begin, sin el el case solo se ejecuta una vez       
      if nom[i] in ['A','E','I','O','U','a','e','i','o','u'] then begin
          linea := linea + nom[i] +' ';
          cant := cant + 1;
       end;
       case uppercase(nom[i]) of // Con el uppecase conviertes la letra a mayusculas y el case actua tanto en maysculas y minusculas
           'A':cont:=1;
           'E':cont:=5;
           'I':cont:=9;
           'O':cont:=6;
           'U':cont:=3;
       end;
end;  // End del for
Memo1.clear;   
 Memo1.Lines.add('Su nombre contiene las vocales');    
Memo1.Lines.Add(linea);    
Memo1.Lines.Add('Total de vocales= '+ IntToStr(Cant));

A partir de aqui mira que es lo que te falla
Responder Con Cita
  #6  
Antiguo 04-06-2015
anonymous anonymous is offline
Miembro
NULL
 
Registrado: may 2015
Posts: 23
Poder: 0
anonymous Va por buen camino
Ayuda con este Problema

BUENAS TENGO UN PROBLEMITA ME QUEDE ATASCADO EN DONDE DICE : Imagen ( Como lo ven los demas ) Imagen1.jpg
No se como descomponer los numeros para hacer la suma no se si me entienden ... DALEE.jpg
CADA LETRA VALE UN NUMERO .. PERO A LA HORA DE DESMENUZAR LAS LETRAS NO SE HACER LA SUMA
este es mi codigo :
Código Delphi [-]
unit JEBUS;

interface

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

type
  TForm3 = class(TForm)
    BitBtn1: TBitBtn;
    Edit1: TEdit;
    Memo1: TMemo;
    Label1: TLabel;
    EdNom: TEdit;
    Label2: TLabel;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}




procedure TForm3.BitBtn1Click(Sender: TObject);
Var i, cant ,cant1,cont,cont1,suma,suma1,resultado,sumav,sumac,p,sumatotal,dig:Integer;
    nom, linea,linea1,linea2,linea3,linea4: string;
begin
   Memo1.Visible:=true;
   nom := EdNom.Text;
   linea := '';
   cant := 0;
   for i:=1 to length(nom) do
      if nom[i] in ['A','E','I','O','U','a','e','i','o','u'] then begin
         linea := linea + nom[i] +' ';
         cant := cant + 1;
      end;


   Memo1.clear;
   Memo1.Lines.add('Su nombre contiene las vocales');
   Memo1.Lines.Add(linea);
   Memo1.Lines.Add('Total de vocales= '+ IntToStr(Cant));

   linea := '';
   cont1:= 0;
   for i := 1 to length (nom) do
   if nom [i] in ['B','C','D','F','G','H','J','K','L','M','Ñ','P','Q','R','S','T','V','W','X','Y','Z','b','c','d','f',  'g','h','j','k','l','m','n','ñ','p','q','r','s','t','v','w','x','y','z'] then
   begin
     linea1 := linea1 + nom[i] +' ';
         cant1 := cant1 + 1;
     end;

   Memo1.Lines.add('-------------------------------- ');
   Memo1.Lines.add('Cantidad de Consonantes');
   Memo1.Lines.Add(linea1);
    Memo1.Lines.Add('Total de Consonantes= '+ IntToStr(Cant1));

  linea := '';
   cant := 0;
   for i:=1 to length(nom) do
   begin
      if nom[i] in ['A','E','I','O','U','a','e','i','o','u'] then
       begin
         linea := linea + nom[i] +' ';
         cant := cant + 1;

 if nom [i] in ['A'] then
      sumav:=sumav+1;
    if nom [i] in ['E'] then
      sumav:=sumav+5;
     if nom [i] in ['I'] then
        sumav:=sumav+9;
        if nom [i] in ['O'] then
            sumav:=sumav+6;
          if nom [i] in ['U'] then
               sumav:=sumav+3;



       end;
   end;


   Memo1.Lines.add('-------------------------------- ');
   Memo1.Lines.Add('ESENCIA (lo que usted Quiere)');
   Memo1.Lines.Add(linea);
   Memo1.Lines.Add(inttostr(sumav));

    linea := '';
   cont1:= 0;
   for i := 1 to length (nom) do
   if nom [i] in ['B','C','D','F','G','H','J','K','L','M','Ñ','P','Q','R','S','T','V','W','X','Y','Z','b','c','d','f',  'g','h','j','k','l','m','n','ñ','p','q','r','s','t','v','w','x','y','z'] then
   begin
     linea1 := linea1 + nom[i] +' ';
         cant1 := cant1 + 1;
 if nom [i] in ['J','S'] then
       sumac:=sumac+1;
        if nom [i] in ['B','K','T'] then
          sumac:=sumac+2;
            if nom [i] in ['C','L'] then
              sumac:=sumac+3;
                if nom [i] in ['D','M','V'] then
                  sumac:=sumac+4;
                    if nom [i] in ['N','W'] then
                      sumac:=sumac+5;
                       if nom [i] in ['F','X'] then
                         sumac:=sumac+6;
                          if nom [i] in ['G','P','Y'] then
                            sumac:=sumac+7;
                             if nom [i] in ['H','Q','Z'] then
                               sumac:=sumac+8;
                               if nom [i] in ['R'] then
                                 sumac:=sumac+9;
               end;



   Memo1.Lines.add('-------------------------------- ');
   Memo1.Lines.Add('IMAGEN (como lo ven los demas)');
   Memo1.Lines.Add(linea1);
   Memo1.Lines.Add(inttostr(sumac));


end;


end.
Responder Con Cita
  #7  
Antiguo 04-06-2015
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.037
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Has batido el record de incumplir las normas de los foros

Bienvenido a clubdelphi, como siempre aconsejamos a los nuevos, no olvides leer nuestra guía de estilo, gracias por tu colaboración



Y recuerda poner los tags al código fuente, ejemplo:



Gracias
Responder Con Cita
  #8  
Antiguo 04-06-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola anonymous.

Combiné el nuevo hilo bajo el título del primero, de hace 6 días, ya que se trata del mismo tema. Al continuar con el tema previo, este pasa a encabezar la lista de nuevos mensajes, no es necesario crear otro con contenido similar.

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #9  
Antiguo 06-06-2015
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
anonymous,

Cita:
Empezado por anonymous
...Ingresando el usuario un Nombre y Apellido (DIEGO ARMANDO MARADONA)...Cada letra tiene su valor...Sumar los números asignados a una palabra...


Revisa este código:
Código Delphi [-]
unit Unit1;

interface

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

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

  TAction = (Esencia = 1, Imagen = 2, Destino = 3, Sendero = 4);

var
  Form1: TForm1;
  ABC : Array['a'..'z'] of Byte = (1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8);

{
Tabla de Pitágoras
1 2 3 4 5 6 7 8 9
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
}

implementation

{$R *.dfm}

function Numerology(Value : String; Action : TAction) : Byte;
var
   SL : TStringList;
   i, j, k : Integer;
   AuxValue, AuxNum : String;
   NumValue : Integer;
   L : Char;

begin

   SL := TStringList.Create;

   ExtractStrings([' ','/','-'], [], PChar(Value), SL);

   Result := 0;

   for i := 0 to SL.Count - 1 do
   begin

      AuxValue := LowerCase(SL[i]);
      NumValue := 0;

      for j := 1 to Length(AuxValue) do
      begin

         L := AuxValue[j];

         if (Action = Esencia) and (L in ['a','e','i','o','u']) then
            NumValue := NumValue + ABC[L];

         if (Action = Imagen) and not (L in ['a','e','i','o','u']) then
            NumValue := NumValue + ABC[L];

         if (Action = Destino) then
            NumValue := NumValue + ABC[L];

         if (Action = Sendero) then
         begin

            if AuxValue[j] in ['0','1','2','3','4','5','6','7','8','9'] then
               NumValue := NumValue + StrToInt(AuxValue[j]);

            if NumValue > 9 then
            repeat

               AuxNum := IntToStr(NumValue);
               NumValue := 0;

               for k := 1 to Length(AuxNum) do
                  NumValue := NumValue + StrToInt(AuxNum[k]);

            until NumValue < 10
           
         end;

      end;

      Result := Result + NumValue;

   end;

   SL.Free;

   if Result in [11,22] then
      Exit;

   if Result > 9 Then
   repeat

      AuxValue := IntToStr(Result);
      Result := 0;

      for j := 1 to Length(AuxValue) do
         Result := Result + StrToInt(AuxValue[j]);

      if Result in [11,22] then
         Break;

   until (Result < 10);

end;

procedure TForm1.Button1Click(Sender: TObject);
var
   Name : String;
   DateBirth : String;

begin

   Name := 'Diego Armando Maradona';
   DateBirth := '30/10/1960';

   ListBox1.Clear;

   ListBox1.Items.Add(Format('Nombre = %s',[Name]));

   ListBox1.Items.Add(Format('Fecha Natal = %s',[DateBirth]));

   ListBox1.Items.Add(Format('Esencia = %d',[Numerology(Name,Esencia)]));

   ListBox1.Items.Add(Format('Imagen = %d',[Numerology(Name,Imagen)]));

   ListBox1.Items.Add(Format('Destino = %d',[Numerology(Name,Destino)]));

   ListBox1.Items.Add(Format('Sendero = %d',[Numerology(DateBirth,Sendero)]));

end;

end.
El código anterior en Delphi 7 sobre Windows 7 Profesional x32, Realiza cálculos numerológicos basados en la información obtenida de las imágenes de los Msg # 1 y #6, como se muestra en la siguiente imagen:



Nota: El código propuesto tiene como único objetivo, servir de guía a los requerimientos planteados en los Msg #1 y Msg #6.

Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 06-06-2015 a las 04:47:33.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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
sumar numeros y separar enteros y fracciones edgar_prospero Varios 5 26-01-2015 05:47:33
sumar dos números y ver resultado con un boton kike22 Varios 2 26-09-2010 19:13:58
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
Evitar perder valores asignados en el constructor de un objeto dec Trucos 0 30-06-2006 13:37:55


La franja horaria es GMT +2. Ahora son las 06:44:10.


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