Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <stdio.h>
- #include <string.h>
- using namespace std;
- int main()
- {
- float juego;
- cout<<" [1] Juego de Parejas :<"<<endl;
- cout<<" [2] Ahorcado x3"<<endl;
- cout<<" [3] Preguntas :D"<<endl;
- cout<<" [4] Matematicas :3"<<endl;
- cout<<" "<<endl;
- cout<<" Elige el juego";
- cin>>juego;
- if (juego=1)
- {
- int x1=-1, y1=-1, x2=-1, y2=-1, adivina[4][4];
- char tablero[4][4], sw=0;
- int i, j, c=0, k=1,ac=0, in=8, n1, n2, u1, u2;
- tablero[0][0]='@';
- tablero[0][1]='*';
- tablero[0][2]='+';
- tablero[0][3]='@';
- tablero[1][0]='$';
- tablero[1][1]='~';
- tablero[1][2]='#';
- tablero[1][3]='%';
- tablero[2][0]='+';
- tablero[2][1]='&';
- tablero[2][2]='$';
- tablero[2][3]='~';
- tablero[3][0]='&';
- tablero[3][1]='#';
- tablero[3][2]='%';
- tablero[3][3]='*';
- for(i=0; i<4; i++)
- {
- for(j=0; j<4; j++)
- {
- adivina[i][j]=k;
- k=k+1;
- }
- }
- do
- { system("cls");
- c++;
- for(i=0; i<4; i++)
- {
- cout<<endl<<endl;
- for(j=0; j<4; j++)
- {
- if((x1==i&&y1==j)||(x2==i&&y2==j)||adivina[i][j]==0)cout<<tablero[i][j]<<"\t";
- else
- cout<<adivina[i][j]<<"\t";
- }
- }
- cout<<endl<<endl;
- cout<<"ACIERTOS= "<<ac<<endl<<endl;
- system("pause");
- cout<<endl<<"digite numero uno: ";
- cin>>n1;
- cout<<"digite numero dos: ";
- cin>>n2;
- if (n1=n2)
- {cout<<"Son el mismo numero campeon, perdiste :3"<<endl;}
- for(i=0; i<4; i++)
- {
- for(j=0; j<4; j++)
- {
- if(adivina[i][j]==n1)
- {
- x1=i;
- y1=j;
- }
- if(adivina[i][j]==n2)
- {
- x2=i;
- y2=j;
- }
- }
- }
- if(tablero[x1][y1]==tablero[x2][y2])
- {
- ac=ac+1;
- adivina[x1][y1]=0;
- adivina[x2][y2]=0;
- }
- if(ac==8||c>=in) sw=1;
- }while(sw==0);
- if(ac==8)
- cout<<"felicidades, pasaste al siguiente juego :3"<<endl;
- else
- cout<<"su numero de intentos termino "<<endl;
- }
- if (juego=2)
- {char palabra[50]=("carloscortez"), rep[100], temp [100];
- int longitud = 0, i, j=0, inicial=0, acierto=0, temporal=0, oport=6;
- bool repetido=false, ganar=false;
- class Juego{
- private:
- char word;
- public:
- void Ahorcado(){
- do{
- temporal=0;
- if(inicial==0){
- for(i=0;i<strlen(palabra);i++){
- if(palabra[i] == ' '){
- temp[i] = ' ';
- longitud++;
- }
- else{
- temp[i] = '_';
- longitud++;
- }
- }
- }
- inicial = 1;
- temp[longitud] = '\0';
- for(i=0;i<strlen(rep);i++){
- if(rep[i] == word){
- repetido = true;
- break;
- }
- else{
- repetido = false;
- }
- }
- if(repetido == false){
- for(i=0;i<strlen(palabra);i++){
- if(palabra[i] == word){
- temp[i] = word;
- acierto++;
- temporal = 1;
- }
- }
- }
- if(repetido == false){
- if(temporal == 0){
- oport = oport - 1;
- }
- }
- else{
- printf("Esa letra ya fue digitada");
- printf("\n\n");
- }
- printf("\n");
- for(i=0;i<strlen(temp);i++){
- printf(" %c ", temp[i]);
- }
- printf("\n");
- if(strcmp(palabra,temp) == 0){
- ganar = true;
- break;
- }
- printf("\n");
- printf("Letras acertadas: %d",acierto);
- printf("\n");
- printf("Oportunidades restantes: %d",oport);
- printf("\n");
- rep[j] = word;
- j++;
- printf("Digita una letra para adivinar la palabra: ");
- scanf("\n%c",&word);
- }while(oport != 0);
- }
- };
- class Imprimir{
- private:
- string mensaje;
- public:
- void setmensaje(string a){
- mensaje = a;
- }
- string getmensaje(){
- return mensaje;
- }
- };
- int main()
- {
- system("CLS");
- rep[0] = ' ';
- rep[1] = '\0';
- Juego Victima;
- Imprimir mostrar;
- Victima.Ahorcado();
- if(ganar){
- printf("\n\n");
- mostrar.setmensaje("Adivinaste la palabra ;3");
- cout<<mostrar.getmensaje();
- }
- else{
- printf("\n\n");
- mostrar.setmensaje("Perdiste?? :< pero puedes volver a intentarlo ");
- cout<<mostrar.getmensaje();
- }
- printf("\n\n");
- system("PAUSE");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement