elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  RETOS C++
0 Usuarios y 3 Visitantes están viendo este tema.
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [15] 16 17 Ir Abajo Respuesta Imprimir
Autor Tema: RETOS C++  (Leído 51,011 veces)
za.asi

Desconectado Desconectado

Mensajes: 62


Ver Perfil
Re: RETOS C++
« Respuesta #140 en: 18 Octubre 2012, 01:45 am »

He encontrado una solución al reto 14, el de los 15200 numeros aleatorios. Lo he provado y funciona bién, al menos en windows.

Código:
#include <iostream>
#include <algorithm>

using namespace std;

int main ()
{
    int contador,
        numg=0;
    for (contador=0; contador<15200; contador++)
    {
        int i=time (0)-contador;
        srand (i);
        int num=rand(),
            numg=max (numg, num);
    }
    cout << "El numero mas alto es: " << numg;
    return 0;
}



« Última modificación: 18 Octubre 2012, 01:49 am por za.asi » En línea

Stakewinner00


Desconectado Desconectado

Mensajes: 1.426



Ver Perfil WWW
Re: RETOS C++
« Respuesta #141 en: 18 Octubre 2012, 07:48 am »

za.asi

x.cpp:11: `time' undeclared (first use this function)


En línea

Puntoinfinito


Desconectado Desconectado

Mensajes: 919


#! /win/archlinux


Ver Perfil WWW
Re: RETOS C++
« Respuesta #142 en: 18 Octubre 2012, 08:41 am »

14-
Código
  1. #include <iostream>
  2. #include <cstime.h>
  3. using namespace std;
  4. int main()
  5. {
  6. int i = 0, j = 0, x = 0;
  7. srand ( time(NULL) );
  8. cout << "Set one nomber : ";
  9. cin >> i;
  10. if (i != 0)
  11. for (int a = 0;i < 15200;i++)
  12. {
  13. rand() % i = j;
  14. if (j > max)
  15. max = x;
  16. }
  17. cout << "The best number : " << max;
  18. }
En línea

AHORA EN SOFTONIC || CLICK HERE!!
Base64: QWNhYmFzIGRlIHBlcmRlciAxIG1pbnV0byBkZSB0dSB2aWRhLiBPbOkh



HACK AND 1337 : http://hackandleet.blogspot.com
WEBSITE: http://www.infiniterware.
za.asi

Desconectado Desconectado

Mensajes: 62


Ver Perfil
Re: RETOS C++
« Respuesta #143 en: 18 Octubre 2012, 14:31 pm »

za.asi

x.cpp:11: `time' undeclared (first use this function)

A mi no me sale error, con un compilador c++ debería ser suficiente con <cstdlib>, pero si no habría que agregar <ctime>.
De todos modos no se por que te sale error, se supone que <cstdlib> incluye la función time ().
En línea

rir3760


Desconectado Desconectado

Mensajes: 1.639


Ver Perfil
Re: RETOS C++
« Respuesta #144 en: 18 Octubre 2012, 16:13 pm »

El prototipo de la función "time" se encuentra en <time.h> (si el lenguaje es C++ se debe utilizar <ctime>).

Un saludo
En línea

C retains the basic philosophy that programmers know what they are doing; it only requires that they state their intentions explicitly.
--
Kernighan & Ritchie, The C programming language
werever19

Desconectado Desconectado

Mensajes: 4


Ver Perfil
Re: RETOS C++
« Respuesta #145 en: 24 Octubre 2012, 19:55 pm »

mando la solucion al 4
Citar
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>

using namespace std;
int main(int argc, const char * argv[])
{   string x, y, w, z;
    vector<string> palabras;
    cout << "inserte 4 palabras";
    cin>>x>>y>>w>>z;
    palabras.push_back(x);
    palabras.push_back(y);
    palabras.push_back(w);
    palabras.push_back(z);
    sort(palabras.begin(), palabras.end());
    cout<<"la primera palabra en el alfabeto es: "<< "\""<<palabras[0]<<"\"";
   
    return 0;
}

En línea

Stakewinner00


Desconectado Desconectado

Mensajes: 1.426



Ver Perfil WWW
Re: RETOS C++
« Respuesta #146 en: 24 Octubre 2012, 20:29 pm »

Actualizado

como paso tanto tiempo nose si a todos sume los que tocan,si me deje alguien que me lo diga.
En línea

leosansan


Desconectado Desconectado

Mensajes: 1.314


Ver Perfil
Re: RETOS C++
« Respuesta #147 en: 24 Octubre 2012, 21:59 pm »

Actualizado

como paso tanto tiempo nose si a todos sume los que tocan,si me deje alguien que me lo diga.
Si te gusto mi solución al diccionario por fuerza bruta que está en esta página, a mí no me habrías sumado los puntos.
Anímate y pon nuevos retos y si se puede te podemos sugerir algunos.
Saludos!.
En línea

Puntoinfinito


Desconectado Desconectado

Mensajes: 919


#! /win/archlinux


Ver Perfil WWW
Re: RETOS C++
« Respuesta #148 en: 24 Octubre 2012, 22:24 pm »

Actualizame la de random numbers + esta :P

De paso el 9: (Solo en Windows)

Código
  1. #include <windows>  
  2. #include <iostream>  
  3.  
  4. using namespace std;  
  5.  
  6. int main(int argc, char *argv[])  
  7. {  
  8.    HWND Proceso;  
  9.    char aux[1000];  
  10.    aux = "hola";
  11.    cin.getline(aux,1000);  
  12.    Proceso = FindWindow(NULL, aux);
  13.    if (hwnd == 0) {
  14.    return 0;
  15.    }
  16.    aux = "adios";  
  17.    cin.getline(aux,1000);  
  18.    SetWindowText(Proceso, aux);
  19.    Proceso = 0;  
  20.    return 0;  
  21. }
« Última modificación: 24 Octubre 2012, 22:38 pm por Puntoinfinito » En línea

AHORA EN SOFTONIC || CLICK HERE!!
Base64: QWNhYmFzIGRlIHBlcmRlciAxIG1pbnV0byBkZSB0dSB2aWRhLiBPbOkh



HACK AND 1337 : http://hackandleet.blogspot.com
WEBSITE: http://www.infiniterware.
Stakewinner00


Desconectado Desconectado

Mensajes: 1.426



Ver Perfil WWW
Re: RETOS C++
« Respuesta #149 en: 25 Octubre 2012, 14:57 pm »

Si te gusto mi solución al diccionario por fuerza bruta que está en esta página, a mí no me habrías sumado los puntos.
Anímate y pon nuevos retos y si se puede te podemos sugerir algunos.
Saludos!.


Siempre acepto sugerencias, este fin de semana pondre nuevos retos.
En línea

Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [15] 16 17 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[RECOPILACION DE RETOS] VBClassic Por 79137913
Programación Visual Basic
79137913 5 14,102 Último mensaje 21 Enero 2013, 18:58 pm
por 79137913
Zona de retos Scripting « 1 2 3 »
Scripting
Eleкtro 23 54,123 Último mensaje 20 Enero 2014, 19:16 pm
por Eleкtro
Retos de java « 1 2 »
Java
4dr14n31t0r 10 5,242 Último mensaje 22 Enero 2016, 16:06 pm
por 0xFer
Retos forenses en español?
Dudas Generales
Sapote 0 1,916 Último mensaje 22 Mayo 2017, 02:58 am
por Sapote
Retos(1 - 15) (wardGame) « 1 2 »
Desafíos - Wargames
4A45414E 14 7,191 Último mensaje 10 Noviembre 2018, 03:16 am
por zonahurbana
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines