Red de conocimiento informático - Conocimiento sistemático - El razonamiento lógico del alto coeficiente intelectual de Einstein

El razonamiento lógico del alto coeficiente intelectual de Einstein

No puedo calcularlo simplemente verbalmente, así que busqué directamente en Internet la siguiente información

1 2 3 4 5

Noruega, Dinamarca, Estados Unidos Reino, Alemania, Suecia

Amarillo azul rojo verde blanco

Dunhill Blend pall mall prinee bine msier

Agua hirviendo té leche café cerveza

Gatos caballos pájaros peces perros

#include lt;iostream.hgt;

char* people[5] = {NULL};

char* color[ 5] = {NULL};

carbón* humo[5] = {NULL};

carbón* bebida[5] = {NULL}; char* pet[5] = {NULL};

/*

char* people[] = {"Noruega", "Dinamarca", "Reino Unido", "Alemania", "Suecia"};

char* color[] = {"amarillo", "azul", "rojo", "verde", "blanco"}; [] = {"Dunhill", "Blend" ","Pall Mall","Prinee","Bine Masier"};

bebida char*[] = {"agua hirviendo", "té" , "leche", "café", "cerveza" };

char* mascota[] = {"gato", "caballo", "pájaro", "pez", "perro"}; /p>

*/

void print_single_result(const char* observación, char* a[])

{

cout lt; lt; lt; endl;

for( int i = 0; i lt; 5; i )

{

if( NULL == a[i ] ] )

cout lt; "NULL";

más

cout lt; cout lt; "\t" lt;

}

cout lt; p> impresión vacía_r

esult()

{

print_single_result("personas", personas

print_single_result("color", color

); print_single_result("fumar", fumar);

print_single_result("beber", beber

print_single_result("mascota", mascota

}

int foo(const int nivel);

int main()

{

if( 0 == foo(0) )

{

print_result();

}

devuelve 0; p>Arriba

{

/*

0. (bebida[2]=="Leche")

1. ( people[0]=="Noruega")

2. (people[i]=="UK"amp; color[i]=="red")

3. (people[i]=="Suecia"amp;amp;pet[i]=="perro")

4. (people[i]=="Dinamarca"amp;amp;bebida [i ]=="té")

5. (color[i]=="verde"&bebida[i]=="café")

6 (fumar[. i]=="Bine Masier"amp; beber[i]=="Cerveza")

7. (fumar[i]=="Pall Mall"amp; pet[i]== "pájaro")

8. (color[i]=="amarillo"amp; humo[i]=="Dunhill")

9. (personas[i]= ="Alemania"&smoke[i]=="Prinee")

10. (color[i]=="Verde"amp;amp;color [j]=="白" amp;amp;(ilt;j))

11. (humo[i]=="Dunhill"amp;amp;pet[j]=="caballo" amp;amp;(i=j -1||i=j 1))

12. (humo[i]=="Mezclar"amp;amp;pet[j]=="gato" amp;amp;(i=j -1||i=j 1))

13. (people[i]=="Noruega"amp;amp;color[j]=="azul "amp;amp;(i=j -1||i=j 1))

14. (beber[i]=="agua hirviendo"am

p;amp;smoke[j]=="Blend"amp;amp;(i=j-1||i=j 1))

*/

cambiar(nivel )

{

caso 0:

{

int isNull = 0

if( beber[ 2] != NULL amp; strcmp(bebida[2], "leche") ) devuelve 1

if( bebida[2] == NULL ) esNull = 1; if( isNull ) bebida[2] = "leche";

if( 0 == foo(level 1) ) return 0

if( isNull ) bebida[2 ] = NULL;

devolver 1;

}

romper;

caso 1:

{

int isNull = 0;

if( personas[0] != NULL amp; strcmp(personas[0], "Noruega") ) return

if; ( personas[0] == NULL ) isNull = 1;

if( isNull ) personas[0] = "Noruega"

if( 0 == foo (nivel 1) ) devuelve 0;

if( isNull ) personas[0] = NULL

devuelve 1; /p>

caso 2:

{

int i = 0;

for( i = 0; i lt; 5 ; i )

{

int isNull1=0, isNull2=0;

if( personas[i] != NULL amp; amp; strcmp(personas [i], "Reino Unido") ) continuar

if( color[i] != NULL amp; strcmp(color[i], "rojo") ) continuar

if( people[ i] == NULL ) esNull1 = 1;

if( color[i] == NULL ) isNull2 = 1;

if( isNull1 ) personas[i] = "Reino Unido"

if( isNull2 ) color[i] = "Rojo";

if( 0 == foo(level 1) ) return 0

if( isNull1 ) personas[i] = NULL; if( isNull2 ) color[i] = NULL

}

devolver 1;

}

romper;

caso 3:

{

int i = 0;

for( i = 0; i lt; 5; i)

{

int isNull1=0, isNull2=0;

if( personas[i] != NULL amp; amp; strcmp(personas[i], "Suecia" ) ) continuar

if( mascota[i] != NULL amp; strcmp(pet[i], "perro") ) continuar

if( personas[i ] = = NULL ) isNull1 = 1;

if( pet[i] == NULL ) isNull2 = 1;

if( isNull1 ) personas[i] = "Suecia"; p>

if( isNull2 ) pet[i] = "perro";

if( 0 == foo(nivel 1) ) return

if( isNull1 ) personas[i] = NULL;

if( isNull2 ) mascota[i] = NULL

}

return 1; }

descanso;

caso 4:

{

int i = 0

para (i; = 0; i lt; 5; i)

{

int isNull1=0, isNull2=0;

amp; amp; strcmp(personas[i], "Dinamarca") ) continuar

if( bebida[i] != NULL amp; amp; strcmp(bebida[i], "té") ) continuar

si( personas[i] == NULL ) esNull1 = 1

si( bebida[i] == NULL ) esNull2 = 1; > if( isNull1 ) personas[i] = "Dinamarca";

if( isNull2 ) bebida[i] = "té"

if( 0 == foo(nivel 1); ) ) devuelve 0;

if( isNull1 ) personas[i] = NULL;

if( isNull2 ) bebida[i] = NULL; /p>

devolver 1;

}

romper

Arriba

{

int; i = 0;

for( i = 0; i lt; 5; i )

{

int isNull1=0, isNull2=0

p>

if( color[i] != NULL amp; amp; strcmp(color[i], "verde") ) continuar

if( beber[i] != NULL amp; strcmp(bebida[i], "café") ) continuar

if( color[i] == NULL ) isNull1 = 1; ( bebida[i] == NULL ) isNull2 = 1;

if( isNull1 ) color[i] = "verde"

if( isNull2 ) bebida[i] = " café";

p>

if( 0 == foo(level 1) ) devuelve 0;

if( isNull1 ) color[i] = NULL;

if( isNull2 ) beber[ i] = NULL

}

devolver 1

}

descanso;

caso 6:

{

int i = 0;

for( i = 0; i lt; 5; i)

{

int isNull1=0, isNull2=0;

if( humo[i] != NULL amp; amp; strcmp(humo[i], "Bine Masier") ) continuar;

if( beber[i] != NULL amp; strcmp(beber[i], "cerveza") ) continuar

if( fumar[i] = = NULL; ) esNull1 = 1;

if( beber[i] == NULL ) isNull2 = 1;

if( isNull1 ) fumar[i] = "Bine Masier"; >

if( isNull2 ) beber[i] = "cerveza";

if( 0 == foo(level 1) ) return

if( isNull1 ) fumar; [i] = NULL;

if( isNull2 ) bebida[i] = NULL

}

return 1;

descanso;

caso 7:

{

int i = 0

for( i = 0; i lt; 5; i)

{

int isNull1=0, isNull2=0

if( humo[i] != NULL amp; ; strcmp(humo[i], "Pall Mall") ) continuar

if( pet[i] != NULL amp; strcmp(pet[i], "bird" ) ) continuar; p>

if( humo[i] == NULL ) esNull1 = 1;

if( pet[i] == NULL ) esNull2 = 1

if( esNull1; ) humo[i] = "Pall Mall"

if( isNull2 ) mascota[i]

= "pájaro";

if( 0 == foo(level 1) ) return 0;

if( isNull1 ) smoke[i] = NULL; > if( isNull2 ) pet[i] = NULL

}

retorno 1;

}

descanso; >

caso 8:

{

int i = 0;

for( i = 0; i lt; 5; i)

{

int isNull1=0, isNull2=0

if( color[i] != NULL amp; amp; strcmp(color[i], "Amarillo ") ) continuar;

if( humo[i] != NULL amp; amp; strcmp(humo[i], "Dunhill") ) continuar;

if( color[ i] == NULL ) isNull1 = 1;

if( humo[i] == NULL ) isNull2 = 1;

if( isNull1 ) color[i] = "amarillo" ;

if( isNull2 ) smoke[i] = "Dunhill"

if( 0 == foo(level 1) ) return

if( ( isNull1 ) color[i] = NULL

if( isNull2 ) humo[i] = NULL

}

return 1;

}

descanso

caso 9:

{

int i = 0; for( i = 0; i lt; 5; i)

{

int isNull1=0, isNull2=0

if( personas[i] != NULL amp; strcmp(people[i],"Alemania") ) continuar

if( smoke[i] != NULL amp; strcmp(smoke[i],"Prinee ") )

continuar

si( personas[i] == NULL ) esNull1 = 1

si( humo[i] == NULL ) esNull2 = 1; > if( isNull1 ) personas[i] = "Alemania";

if( isNull2 ) humo[i] = "Prinee"

if( 0 == foo(nivel 1); ) ) devuelve 0;

if( isNull1 ) personas[i] = NULL;

if( isNull2 ) humo[i] = NULL

}

devolver 1;

}

romper

Arriba

{

int; i = 0;

for( i = 0; i lt; 5; i )

{

int isNull1=0

> if( color[i] != NULL amp; strcmp(color[i], "verde") ) continuar

if( color[i] == NULL ) isNull1 = 1; >

if( isNull1 ) color[i] = "verde";

int j

for( j = i 1; j lt; 5; j )

{

int isNull2=0;

if( color[j] != NULL amp; amp; strcmp(color[j], "blanco") ) continuar

if( color[j] == NULL ) esNull2 = 1

if( isNull2 ) color[j] = "blanco"; if( 0 == foo(level 1) ) return 0

if( isNull2 ) color[j] = NULL

}

if ( isNull1; ) color[i] = NULL;

}

devolver 1;

}

romper; do

ejemplo 11:

{

int i = 0;

for( i = 0; i lt; 5; i)

{

int isNull1=0;

if( humo[i] != NULL amp; amp; strcmp(humo[i], "Dunhill") ) continuar

if( humo[i] == NULL ) esNull1 = 1

if( isNull1 ) humo[i] = "Dunhill"

if( i-1gt; ;=0 )

{

int j = i-1;

int isNull2=0; ] == NULL || !strcmp(pet[j],"马") )

{

if( pet[j] == NULL ) isNull2 = 1

if( isNull2 ) pet[j] = "caballo";

if( 0 == foo(nivel 1) ) return

if( isNull2 ) mascota[j] = NULL

}

}

si( i 1lt;=4)

{

int j = i 1;

int isNull2=0

if( mascota[j] == NULL || !strcmp(pet[j], "caballo" ) )

{

if( pet[j] == NULL ) isNull2 = 1

if( isNull2 ) pet[j] = "caballo" ;

if( 0 == foo(nivel 1) ) devuelve 0

if( isNull2 ) pet[j] = NULL; p>

p>

}

if( isNull1 ) humo[i] = NULL

}

return 1; >

}

descanso

caso 12:

{

int i = 0;

p> for( i = 0; i lt; 5; i)

{

int isNull1=0

if( humo[i] != NULL amp; strcmp(humo[i], "Blend") ) continuar

si( humo[i] == NULL ) esNull1 = 1; ) humo[i] = "Mezclar";

if( i-1gt; =0 )

{

int j = i-1

p>

int isNull2=0;

if( mascota[j] == NULL || !strcmp(pet[j], "gato") )

{

if( mascota[j] == NULL ) esNull2 = 1;

if( isNull2 ) mascota[j] = "gato"; p> if( 0 == foo(level 1) ) return 0;

if( isNull2 ) pet[j] = NULL;

if( i 1lt;=4)

{

int j = i 1

int isNull2=0

if( mascota[j] == NULL || !strcmp(pet[j],"gato") )

{

if( mascota[j] == NULL ) isNull2 = 1;

if( isNull2 ) pet[j] = "gato"

if( 0 == foo(nivel 1) ) return 0; /p>

if( isNull2 ) pet[j] = NULL

}

}

if( isNull1 ) humo[i] = NULL; ;

}

retorno 1;

}

descanso

caso 13:

{

int i = 0;

for( i = 0; i lt; 5; i)

{

int isNull1=0;

if( personas[i] != NULL amp; strcmp(personas[i], "Noruega") ) continuar

if( personas[i] == NULL ) isNull1 = 1;

if( isNull1 ) personas[i] = "Noruega"

if( i-1gt; =0; )

{

int j = i-1;

int isNull2=0

if( color[j] ==; NULL || !strcmp(color[j], "Azul") )

{

if( color[j] == NULL ) isNull2 = 1; p> p>

if( isNull2 ) color[j] = "azul"

if( 0 == foo(level 1) ) return

if( isNull2 ) color[j] = NULL

}

}

if( i 1lt;=4 )

{

int j = i 1;

int isNull2=0;

if( color[j] == NULL || !strcmp(color[j], " Color azul") )

{

if( color[j] == NULL ) isNull2 = 1;

if( isNull2 ) color[j] = "azul";

if( 0 == foo(level 1) ) return 0

if( isNull2 ) color[j] = NULL; }

}

if( isNull1 ) personas[i] = NULL

}

devuelve 1; p> }

descanso

caso 14:

{

int i = 0

para; (i = 0; i lt; 5; i)

{

int isNull1=0

if(

beber[i] != NULL amp; strcmp(beber[i], "agua hirviendo") ) continuar

if( beber[i] == NULL ) isNull1 = 1; p> if( isNull1 ) beber[i] = "agua hirviendo"

if( i-1gt;=0 )

{

int j = i-1;

int isNull2=0;

if( humo[j] == NULL || !strcmp(humo[j], "Blend")

{

if( humo[j] == NULL ) esNull2 = 1;

if( isNull2 ) humo[j] = "Mezclar"

devolver 0;

}

}

si( i 1lt;=4)

{

int j = i 1;

int isNull2=0;

if( humo[j] == NULL || !strcmp(humo[j], "Mezclar") )

{

if( humo[j] == NULL ) esNull2 = 1;

if( isNull2 ) humo[j] = "Mezclar";

devuelve 0;

}

}

si( isNull1 ) bebida[i] = NULL

}

devolver 1;

}

romper;

predeterminado:

romper

}

devuelve 1;

}