Hey, Yo soy Miguel Angel y estas en mi blog personal, espero que el contenido de este blog te sea de mucha ayuda.

Hallar el numero mayor y menor de un rango permitido

lunes, 10 de febrero de 2014


#include < stdio.h>
#include < conio.h>
#include < stdlib.h>
#include < string.h>
#include < math.h>
int LeerDato(char Mensaje[])
{
   int Num;
   printf("%s",Mensaje);
   scanf("%d",&Num);
   fflush(stdin);
   return Num;
}
int LeerRpta(char Mensaje[])
{
    char cadena[1001];

    printf("%s",Mensaje);
    gets(cadena);
    if(strcmp(cadena,"Continuar")==0)
      {
   		return 1;
      }
    else
      	return 0;
}
void Codigo(int &i,int &Num, int &a,int &b,int &c,int &d,int &e,int &f)
{
   int Cont,Cont1=0;
  	for(i=0; i< log10(Num)+1;i++)
   {
      Cont=pow(10,i+1);
      Cont1=(Num%Cont)-Cont1;
      if (i==0)
          a=a+(Cont1/pow(10,i));
      if (i==1)
          b=b+(Cont1/pow(10,i));
      if (i==2)
          c=c+(Cont1/pow(10,i));
      if (i==3)
          d=d+(Cont1/pow(10,i));
      if (i==4)
          e=e+(Cont1/pow(10,i));
      if (i==5)
          f=f+(Cont1/pow(10,i));
   }
}

int Contador(int i,int &Num, int a, int b, int c, int d, int e, int f)
{
	int Cont;
   Codigo(i,Num,a,b,c,d,e,f);

   Cont=i;
   return Cont;



}
void evaluar(int i,int &Num, int a, int b, int c, int d, int e, int f)
{
    int may=0;

   Codigo(i,Num,a,b,c,d,e,f);
   if(a>=b && a>=c && a>=d && a>=e && a>=f)
   	may=may+a;
   if(b>a && b>=c && b>=d && b>=e && b>=f)
      may=may+b;
   if(c>a && c>b && c>=d && c>=e && c>=f)
      may=may+c;
   if(d>a && d>b && d>c && d>=e && d>=f)
      may=may+d;
   if(e>a && e>b && e>c && e>d && e>=f)
      may=may+e;
    if(f>a && f>b && f>c && f>d && f>e)
      may=may+f;
   printf("\n\nEl mayor codigo del numero %d es: %d ",Num,may);
}

int Menor1(int i,int &Num,int a, int b, int c, int d, int e, int f)
{
    Codigo(i,Num,a,b,c,d,e,f);
    int men;

    men=a;
    return men;
}
int Menor2(int i,int &Num,int a, int b, int c, int d, int e, int f)
{
    Codigo(i,Num,a,b,c,d,e,f);
    int men;

    if(a< =b)
    	men=a;
    else
    	men=b;
    return men;
}
int Menor3(int i,int &Num,int a, int b, int c, int d, int e, int f)
{
    Codigo(i,Num,a,b,c,d,e,f);
    int men;
    if(a<=b && a<=c)
    	men=a;
    if(b< a && b<=c)
    	men=b;
    if(c< a && c< b)
    	men=c;
    return men;
}
int Menor4(int i,int &Num,int a, int b, int c, int d, int e, int f)
{
    Codigo(i,Num,a,b,c,d,e,f);
    int men;
    if(a< =b && a<=c && a<=d)
   	men=a;
    if(b< a && b<=c && b<=d)
   	men=b;
    if(c< a && c< b && c<=d)
   	men=c;
    if(d< a && d< b && d< c)
   	men=d;
    return men;
}
int Menor5(int i,int &Num,int a, int b, int c, int d, int e, int f)
{
    Codigo(i,Num,a,b,c,d,e,f);
    int men;
    if(a<=b && a<=c && a<=d && a<=e)
    	men=a;
    if(b< a && b<=c && b<=d && b<=e)
    	men=b;
    if(c< a && c< b && c<=d && c<=e)
    	men=c;
    if(d< a && d< b && d< c && d<=e)
    	men=d;
    if(e< a && e< b && e< c && e< d)
    	men=e;
    return men;
}
int Menor6(int i,int &Num,int a, int b, int c, int d, int e, int f)
{
    Codigo(i,Num,a,b,c,d,e,f);
    int men;
    if(a<=b && a<=c && a<=d && a<=e && a<=f)
    	men=a;
  	 if(b< a && b<=c && b<=d && b<=e && b<=f)
    	men=b;
    if(c< a && c< b && c<=d && c<=e && c<=f)
    	men=c;
    if(d< a && d< b && d< c && d<=e && d<=f)
    	men=d;
    if(e< a && e< b && e< c && e< d && e<=f)
    	men=e;
    if(f< a && f< b && f< c && f< d && f< e)
    	men=f;
    return men;
}
void evaluar2(int Men,int i,int &Num,int a, int b, int c, int d, int e, int f)
{
   	int Cont1;
      Cont1=Contador(i,Num,a,b,c,d,e,f);

      if (Num==1)
      {
          printf("\n\nEl menor codigo del numero %d es: %d ",Num,Num);
      }
		if(Cont1==2)
      {
      	Men=Menor1(i,Num,a,b,c,d,e,f);
         printf("\n\nEl menor codigo del numero %d es: %d ",Num,Men);
      }
      if(Cont1==3)
      {
         Men=Menor2(i,Num,a,b,c,d,e,f);
         printf("\n\nEl menor codigo del numero %d es: %d ",Num,Men);
      }
      if(Cont1==4)
      {
         Men=Menor3(i,Num,a,b,c,d,e,f);
         printf("\n\nEl menor codigo del numero %d es: %d ",Num,Men);
      }
      if(Cont1==5)
      {
         Men=Menor4(i,Num,a,b,c,d,e,f);
         printf("\n\nEl menor codigo del numero %d es: %d ",Num,Men);
      }
      if(Cont1==6)
      {
         Men=Menor5(i,Num,a,b,c,d,e,f);
         printf("\n\nEl menor codigo del numero %d es: %d ",Num,Men);
      }
      if(Cont1==7)
      {
         Men=Menor6(i,Num,a,b,c,d,e,f);
         printf("\n\nEl menor codigo del numero %d es: %d ",Num,Men);
		}

}

void main()
{

	printf (" \n Mayor y menor de codigos. \n");
	printf ("Pulse enter para iniciar\n");
	getch ();
	clrscr( );
	int Men=0,i=0,Num,a=0,b=0,c=0,d=0,e=0,f=0;
   int Rpta;
   do
   {
   	clrscr();
   	do
   	{
   		Num=LeerDato("Ingrese Numero: Rango < 0-1000000>");
   	}while(Num< 0 || Num>=1000000);
      evaluar(i,Num,a,b,c,d,e,f);

      evaluar2(Men,i,Num,a,b,c,d,e,f);

      Rpta=LeerRpta("\nDesea Continuar- (Continuar)- (Salir)");
   }while(Rpta==1);
   getch();
}

[C++] Leer un texto por pantalla y mostrar como salida la cantidad de vocales en dicho texto


EJERCICIO RESULTO

Leer un texto por pantalla y mostrar como salida la cantidad de vocales en dicho texto.
Debe continuarse hasta que no se desee.

//Quitar el espacio que hay despues del "<" en los include lo agrege por cuestion de problemas en la sintaxis en mi web
#include< stdio.h>
#include< stdlib.h>
#include< conio.h>
#include< string.h>

void leerdatos(char cadena[])
{
 printf("\n\1:: INGRESE UN TEXTO \1::   ");
 fflush();
 gets(cadena);
}



int contarvocales(char cadena[])
 {
 int cont1=0,total;
  total=strlen(cadena);
   for(int i=0;i < total;i++){
    if(cadena[i]=='a' || cadena[i]=='e' || cadena[i]=='i' || cadena[i]=='o' || cadena[i]=='u')
    cont1++;
    }
    return  cont1++;
}



void procesa(char cadena[])
{
 int cont1;

 leerdatos(cadena);
 cont1=contarvocales(cadena);
 if(cont1>0)
   printf("\n\4El texto contiene  %d vocales! \n  ",cont1);
 else
   printf("\n\4El texto no contiene vocales! \n ");

 }


void main()
{
char cadena[20];
char Resp;
do{
   procesa(cadena);
   printf("\nContinuar(C) - Salir(S) ::\n");
   scanf("%s",&Resp);
}while(Resp=='c' || Resp=='C');

getch();
}

[PHP] Pusher comunicación en tiempo real

Pusher comunicación en tiempo real

Hace 1 año aproximadamente realice un hangout con los amigos de Ninjacode explicando el uso de la herramienta pusher, esta herramienta nos permite hacer peticiones y envío de datos en tiempo real, teniendo como base el motor de nodejs en el cual esta construido.

Te invito a darle un vistazo e este video donde explico la manera de uso.

Puedes obtener mas información en la pagina oficial de pusher: 


[Release] Modo Gun para Gunz 1.5

lunes, 3 de febrero de 2014

Manual Gun Mode Source 1.5Gunz The Duel

Manual para agregar a tu código fuente el nuevo modo de juego para Gunz. El GunMode hasta ahora ha sido presentado por algunos servidores con 2 distintos sistemas lógicos.
  1. El Gun Mode consiste en que durante una ronda, los personajes tienes un cierto rango de Niveles los cuales se aumentan matando a otros personajes, y por cada Kill recibirán de forma ALEATORIA un paquetes de armas(espada,arma primaria, arma secundaria).
  2. El Gun Mode consiste en que durante una ronda, los personajes tienes un cierto rango de Niveles los cuales se aumentan matando a otros personajes, mediante un sistema que promedia los Kills y requiere por cada nivel mayor cantidad de Kills para poder pasar al siguiente nivel y premiar con un paquetes de armas(espada,arma primaria, arma secundaria) las cuales son de mejor nivel según el nivel del Gun Mode.
Para este manual nos estamos basando en el primero caso, ya que en el primero necesitamos unos pocos paquetes de armas.


----------------------------


Aclaración: Este modo de juego a sido programado y codeado en base a mi lógica y conocimiento de programación, no es extraído de algún código fuente de otros servidores.

Datos:
Este modo de juego se codeo en base a los sources de (Gunz 1.5 Repack By jur13n).

CSCommon\Include\MBaseGameType.h:
//Buscar esta linea:
MMATCH_GAMETYPE_CTF      =12,
//Pegar esta debajo:
MMATCH_GAMETYPE_GUNMODE  =13,
CSCommon\Include\MMatchRule.h:
//Buscar esta linea:
(nGameType == MMATCH_GAMETYPE_DEATHMATCH_SOLO) || 
//Pegar esta debajo:
(nGameType == MMATCH_GAMETYPE_GUNMODE) ||
CSCommon\Include\MMatchRuleDeathMatch.h:
Buscar:
//Buscar esta linea:

class MMatchRuleSoloDeath : public MMatchRule {
protected:
 bool CheckKillCount(MMatchObject* pOutObject);
 virtual void OnBegin();
 virtual void OnEnd();
 virtual void OnRoundTimeOut();
 virtual bool OnCheckRoundFinish();
 virtual bool RoundCount();
public:
 MMatchRuleSoloDeath(MMatchStage* pStage);
 virtual ~MMatchRuleSoloDeath() { }
 virtual MMATCH_GAMETYPE GetGameType() { return MMATCH_GAMETYPE_DEATHMATCH_SOLO; }
};

//Pegar esta debajo:

class MMatchRuleGunMode : public MMatchRule {
protected:
 bool CheckKillCount(MMatchObject* pOutObject);
 virtual void OnBegin();
 virtual void OnEnd();
 virtual void OnRoundTimeOut();
 virtual bool OnCheckRoundFinish();
 virtual bool RoundCount();
public:
 MMatchRuleGunMode(MMatchStage* pStage);
 virtual ~MMatchRuleGunMode() { }
 virtual MMATCH_GAMETYPE GetGameType() { return MMATCH_GAMETYPE_GUNMODE; }
};

CSCommon\Source\MBaseGameType.cpp: 
//Buscar esta linea:

#define MMATCH_GAMETYPE_CTF_STR  "Capture the Flag"

//Pegar esta debajo:

#define MMATCH_GAMETYPE_GUNMODE_STR "GUN MODE"

//Buscar esta linea:

_InitGameType(MMATCH_GAMETYPE_CTF,    MMATCH_GAMETYPE_CTF,    MMATCH_GAMETYPE_CTF_STR,     1.0f,   0.6f,     0.5f);

//pegar debajo:

_InitGameType(MMATCH_GAMETYPE_GUNMODE,    MMATCH_GAMETYPE_GUNMODE,    MMATCH_GAMETYPE_GUNMODE_STR,     1.0f,   1.0f,     0.0f);

//Buscar esta linea:

"CTF",  //CAPTURE THE FLAG

//Pegar debajo

"GM",  //GUNMODE

CSCommon\Source\MMatchRuleDeathMatch.cpp: 
//Buscar esta linea:

void MMatchRuleSoloDeath::OnRoundTimeOut()
{
 SetRoundArg(MMATCH_ROUNDRESULT_DRAW);
}

//pegar debajo:

//////////////////////////////////////////////////////////////////////////////////
// MMatchRuleGunMode ///////////////////////////////////////////////////////////
MMatchRuleGunMode::MMatchRuleGunMode(MMatchStage* pStage) : MMatchRule(pStage)
{

}

void MMatchRuleGunMode::OnBegin()
{

}
void MMatchRuleGunMode::OnEnd()
{
}

bool MMatchRuleGunMode::RoundCount()
{
 if (++m_nRoundCount < 1) return true;
 return false;
}

bool MMatchRuleGunMode::CheckKillCount(MMatchObject* pOutObject)
{
 MMatchStage* pStage = GetStage();
 for (MUIDRefCache::iterator i=pStage->GetObjBegin(); i!=pStage->GetObjEnd(); i++) 
 {
  MMatchObject* pObj = (MMatchObject*)(*i).second;
  if (pObj->GetEnterBattle() == false) continue;

  if (pObj->GetKillCount() >= (unsigned int)pStage->GetStageSetting()->GetRoundMax())
  {
   pOutObject = pObj;
   return true;
  }
 }
 return false;
}

bool MMatchRuleGunMode::OnCheckRoundFinish()
{
 MMatchObject* pObject = NULL;

 if (CheckKillCount(pObject))
 {
  return true;
 }
 return false;
}

void MMatchRuleGunMode::OnRoundTimeOut()
{
 SetRoundArg(MMATCH_ROUNDRESULT_DRAW);
}


CSCommon\Source\MMatchStage.cpp: 
//Buscar esta linea:

case MMATCH_GAMETYPE_CTF:
{
 return (new MMatchRuleTeamCTF(this));
}
break;

//pegar debajo

case MMATCH_GAMETYPE_GUNMODE:
{
 return (new MMatchRuleGunMode(this));
}
break;


Gunz\ZCombatInterface.cpp: 
//Buscar esta linea:

m_nBulletCurrMagazine = 0;

//pegar debajo

m_nGunLevel = 1;

//Buscar esta linea:

DrawMyWeaponPont(pDC);

//pegar debajo

if (ZGetGame()->GetMatch()->GetMatchType()== MMATCH_GAMETYPE_GUNMODE)
{
 char buffer[256];
 sprintf(buffer,"[Level %d / %d ]", m_nGunLevel, ZGetGame()->GetMatch()->GetRoundCount());
 TextRelative(pDC,660.f/800.f,480.f/600.f,buffer);
}
//Este codigo sirve para imprimir en pantalla el nivel de Gunz Mode que tiene el personaje

//Buscar esta linea:

UpdateCombo(pCharacter);

//pegar debajo

m_nGunLevel = AddGunLevel();

//Buscar esta linea:

void ZCombatInterface::ShowInfo(bool bVisible)
{
 MWidget* pWidget;
 char szTemp[256];
 for (int i = 0; i < 9; i++)
 {
  sprintf(szTemp, "%s%d", ZIITEM_COMBAT_INFO, i);
  pWidget = m_pIDLResource->FindWidget(szTemp);
  if (pWidget!=NULL)
  {
   pWidget->Show(bVisible);
  }
 }
 pWidget = m_pIDLResource->FindWidget(ZIITEM_COMBAT_CHATFRAME);
 if (pWidget!=NULL)
 {
  pWidget->Show(bVisible);
 }
}

//pegar debajo

void ZCombatInterface::GunMode(ZCharacter* pCharacter,const int Level){
 // ZGetScreenEffectManager()->AddRoundStart(Level);
 //este es un efecto predeterminado que trae el gunz.
 //No es necesario que sea agregado es opcional. 
  int nItemMelee = 0;
  int nItemPistol = 0;
  int nItemSecun = 0;
//Apartir de aqui se generan los items aleatorios, es un código básico de c++,
// luego lo modificaré para que esto se conecte con XML o SQL, pero por ahora usen este
int aleatorio = rand()%3;
  if(aleatorio == 0)
  {  
   nItemMelee = 7; 
   nItemPistol= 505005;
   nItemSecun= 5019;
  }
  if(aleatorio == 1)
  {  
   nItemMelee = 502013;
   nItemPistol= 504006;
   nItemSecun= 506009;
  }
  if(aleatorio == 2)
  {  
   nItemMelee = 18; 
   nItemPistol = 506007;
   nItemSecun=6006; //braker 8
  }
  
  pCharacter->GetItems()->EquipItem(MMCIP_PRIMARY, nItemPistol);  // Rocket
  pCharacter->ChangeWeapon(MMCIP_PRIMARY);
  pCharacter->ChangeWeapon(MMCIP_PRIMARY);
  pCharacter->GetItems()->EquipItem(MMCIP_SECONDARY, nItemSecun);  // grenade
  pCharacter->ChangeWeapon(MMCIP_SECONDARY);
  pCharacter->GetItems()->EquipItem(MMCIP_MELEE, nItemMelee);  // dagger
  pCharacter->ChangeWeapon(MMCIP_MELEE);
  pCharacter->ChangeWeapon(MMCIP_CUSTOM1);
  pCharacter->ChangeWeapon(MMCIP_CUSTOM2);
  pCharacter->InitItemBullet();
   
}
/*Aqui esta el sistema logico para poder alternar la entrega de armas, en este caso el sistema pide que se genere 
un numero aleatorio entre 0 y 2 (Rango: 0,1,2) es decir tiene 3 posibilidades, con esto generamos las condiciones
en las cuales se configura el ID del arma o item que se le entregará al personaje.
*/
Gunz\ZCombatInterface.h: 
//Buscar esta linea:

int m_nMagazine;

//pegar debajo:

int  m_nGunLevel;

//Buscar esta linea:

bool IsMenuVisible() { return m_bMenuVisible; }

//pegar debajo:

void GunMode(ZCharacter* pCharacter, int GunLevel);

int AddGunLevel(){return m_nGunLevel++;};
Gunz\ZGame.cpp: 
//Buscar esta linea:
if (!bSuicide) 
     pAttacker->GetStatus().Ref().AddKills(); 

//reemplazar por:

if (!bSuicide) 
{
 pAttacker->GetStatus().Ref().AddKills(); 
 if (GetMatch()->GetMatchType() == MMATCH_GAMETYPE_GUNMODE && pVictim != m_pMyCharacter)
 {

  ZGetCombatInterface()->GunMode(pAttacker,pAttacker->GetKils());
  ZGetCombatInterface()->AddGunLevel();
 }
}


//Buscar esta linea:

bool IsMenuVisible() { return m_bMenuVisible; }

//pegar debajo:

void GunMode(ZCharacter* pCharacter, int GunLevel);

int AddGunLevel(){return m_nGunLevel++;};

Gunz\ZGameInterface.cpp: 
//Buscar esta linea:

ZGetGameTypeManager()->SetGameTypeStr( MMATCH_GAMETYPE_CTF, ZMsg( MSG_MT_CTF)); 

//pegar debajo:

ZGetGameTypeManager()->SetGameTypeStr( MMATCH_GAMETYPE_GUNMODE, "GunMode");

Gunz\ZRule.cpp: 
//Buscar esta linea:

case MMATCH_GAMETYPE_DEATHMATCH_SOLO:
{
 return (new ZRuleSoloDeathMatch(pMatch));
}
break;

//pegar debajo:

case MMATCH_GAMETYPE_GUNMODE:
{
 return (new ZRuleGunMode(pMatch));
}
break;


Gunz\ZRuleDeathMatch.cpp: 
//Buscar esta linea:

ZRuleSoloDeathMatch::ZRuleSoloDeathMatch(ZMatch* pMatch) : ZRule(pMatch)
{

}

ZRuleSoloDeathMatch::~ZRuleSoloDeathMatch()
{





}

//pegar debajo:

/////////////////////////////////////////////////////////////////////////////////////////
ZRuleGunMode::ZRuleGunMode(ZMatch* pMatch) : ZRule(pMatch)
{

}

ZRuleGunMode::~ZRuleGunMode()
{





}

Gunz\ZRuleDeathMatch.h: 
//Buscar esta linea:

class ZRuleSoloDeathMatch : public ZRule
{
public:
 ZRuleSoloDeathMatch(ZMatch* pMatch);
 virtual ~ZRuleSoloDeathMatch();
};

//pegar debajo:

class ZRuleGunMode : public ZRule
{
public:
 ZRuleGunMode(ZMatch* pMatch);
 virtual ~ZRuleGunMode();
};


Gunz\ZStageInterface.cpp: 
//Buscar esta linea:

case MMATCH_GAMETYPE_DEATHMATCH_SOLO:
color = SDM_COLOR;
break;


//pegar debajo:

case MMATCH_GAMETYPE_GUNMODE:
color = SDM_COLOR;
break;

//Buscar esta linea:

ZApplication::GetGameInterface()->UpdateBlueRedTeam();

 // °ÔÀÓ ¹æ½Ä¿¡ µû¶ó¼­ UI¸¦ º¯°æÇÑ´Ù
 MAnimation* pAniMapImg = (MAnimation*)pResource->FindWidget( "Stage_MapNameBG");
 bool bQuestUI = false;
 if ( (pSetting->nGameType == MMATCH_GAMETYPE_DEATHMATCH_SOLO) || 

//pegar debajo:

(pSetting->nGameType == MMATCH_GAMETYPE_GUNMODE) ||


//Buscar esta linea:
MWidget* pWidget = ZApplication::GetGameInterface()->GetIDLResource()->FindWidget( "StageRoundCountLabel");
 if ( pWidget)
 {
  if ((pSetting->nGameType == MMATCH_GAMETYPE_DEATHMATCH_SOLO) ||

//pegar debajo:

(pSetting->nGameType == MMATCH_GAMETYPE_GUNMODE) ||

Historial:

  • Nivel inicial = 1 [Corregido]
  • Efecto Round * [Removido]
  • Conexión a SQL Serv [Proceso]

Resultado Final:


Copyright @ 2013 AnguelSC. Designed by Templateism | MyBloggerLab