void main() { int i, j, vector1[7], vector2[5], vector3[12], k, numi, numi2; printf(" ##### EJERCICIO 4 ##### \n"); printf("Introduce los datos del primer vector. \n"); intro(vector1, 7); printf("Introduce los datos del segundo vector. \n"); intro(vector2, 5); ordena(vector1, 7); ordena(vector2, 5); for(k=0, numi=0, numi2=0; k<12; k++) { if(numi2>=5 || (numi<7 && vector1[numi]<vector2[numi2])) { vector3[k]=vector1[numi]; numi++; } else { vector3[k]=vector2[numi2]; numi2++; } } muestra(vector1, 7); muestra(vector2, 5); muestra(vector3, 12); fflush(stdin); getchar(); }
int main(int argc, const char **argv){ struct TCurriculo angel = { "Angel", 4, 7, 9 }; struct TCurriculo victor = angel; strcpy(victor.nombre, "Victor"); angel = victor; printf("Angel:\t%p\nVictor:\t%p\n", angel.nombre, victor.nombre); muestra(angel); muestra(victor); return EXIT_SUCCESS; }
int Menu(){ printf("\033[0m Menú principal \n Opciones:\n 1)ENVIAR MENSAJES\n 2)LISTA DE AMIGOS \n 3)AGREGAR AMIGOS \n Digite 0 para salir del programa\n"); int salir=0; int opcion; while(salir==0){ opcion=-1; fflush(stdin); scanf("%d",&opcion); if (opcion==1){ system("clear"); // Se llama a la función sockets para crear la comunicación entre los nodos sockets(); Menu();} else if (opcion==2){ system("clear"); muestra(); // Se llama a la función mostrar para desplegar la lista de contactos que se posee Menu();} else if (opcion==3){ system("clear"); Escribir(); // En esta opción permite al usuario agregar amigos Menu();} else exit(0); } return 0; }
int main () { Persona P, R; printf("Ingreso de datos\n"); llenar(&P); printf("Ingreso de datos\n"); llenar2(&R); printf("Muestra de datos\n"); muestra(P); printf("Muestra de datos\n"); muestra(R); system("pause"); }
void muestra(int numero){ static int posicion = 0; if (numero / 10 > 0){ posicion++; muestra(numero / 10); posicion--; } printf("%s ", ordinal[posicion][numero % 10]); }
void muestra_lista(tPunteroNodo* cabeza){ tPunteroNodo aux; printf("Lista\n"); while(aux!=NULL){ printf("ID:%s\n",aux->identificador); muestra(aux->conjunto); aux=aux->sig; } }/*funciona*/
int main(int argc, char *argv[]){ int fibonacci[MAX]; calcula(fibonacci); muestra(fibonacci); return EXIT_SUCCESS; }
//******************************************************************* void arreglo::muestra(int pos) //Este m‚todo despliega en pantalla { //los elementos contenidos en el arreglo. if(pos>=n) cout<<"\n \tSe ha mostrado el contenido del arreglo\n"; else { cout<<"\tNumero "<<pos+1<<": "<<A[pos]<<endl; muestra(pos+1); } }
void arreglo::muestra(int pos) //Metodo mostrar contenido del arreglo { if(pos>=n) cout<<"\n \tSe ha mostrado el contenido del arreglo\n"; else { cout<<"\tNumero "<<pos+1<<": "<<A[pos]<<endl; muestra(pos+1); } }
int main(int argc, const char **argv){ int numero; scanf(" %i", &numero); muestra(numero); printf("\n"); return EXIT_SUCCESS; }
int main(int argc, char **argv){ char name; pregunta(name); muestra(name); return EXIT_SUCCESS; }
int main(int argc, char *argv[]){ Serpiente serpiente; serpiente.longitud = L0; struct TCoordenada movimiento = {0, -1}; int user_input; srand(time(NULL)); rellena(&serpiente); initscr(); // Crea una matriz para pintar halfdelay(3); // Hace que getch espere 3 decimas de segundo keypad(stdscr, TRUE); // Vale para leer las flechas noecho(); // Para que no se vea el caracter pulsado. curs_set(0); // No se ve el cursor. while((user_input = getch()) != ESC){ switch(tolower(user_input)){ case 'q': case KEY_UP: movimiento.x = 0; movimiento.y = -1; break; case 'a': case KEY_DOWN: movimiento.x = 0; movimiento.y = 1; break; case 'o': case KEY_LEFT: movimiento.x = -1; movimiento.y = 0; break; case 'p': case KEY_RIGHT: movimiento.x = 1; movimiento.y = 0; break; } mover( movimiento, &serpiente); muestra(&serpiente); } endwin(); // Libera la matriz. return EXIT_SUCCESS; }
void calcula (float matriz[][TAM]) { int i,u,diagonalprin=0,diagonalsec=0,inferiorprin=0,superiorprin=0,superiorsec=0,inferiorsec=0; for(i=0; i<TAM; i++) { for(u=0; u<TAM; u++) { if(i==u) diagonalprin+=matriz[i][u]; else if(i<u) superiorprin+=matriz[i][u]; else inferiorprin+=matriz[i][u]; if(i+u==TAM-1) diagonalsec+=matriz[i][u]; else if(i+u<=TAM-2) superiorsec+=matriz[i][u]; else inferiorsec+=matriz[i][u]; }; }; muestra(diagonalprin,superiorprin,inferiorprin,diagonalsec,superiorsec,inferiorsec); }
int main (int argc, char *argv[]) //MAIN FUCNTION { //matriz del juego //Game "Board" with the dots char av[25][80]= { "*******************************************************************************", "*.............................................................................*", "*...***********.............***********..................***** *****..........*", "*...***********.............***********..................*...*.*...*..........*", "*...**......................***********..................*.........*..........*", "*...**.********.............***********..................*...*.*...*..........*", "*...**......................***********..................***** *****..........*", "*...***********...............................................................*", "*...***********...............*********............*********..................*", "*............**...............*********............*********..................*", "*...***********...............*********............*********..................*", "*...***********...............................................................*", "*..............................*************************************..........*", "*..............................*************************************..........*", "*....***********...............*************************************..........*", "*....***********..............................................................*", "*....***********...................................................******.....*", "*........................*******************.......................******.....*", "*.....****...............*******************.*********************.******.....*", "*.....******.............***.............***.......................******.....*", "*.....*********..........***....*****....***.......................******.....*", "*.....*********..........***....*****....***.......................******.....*", "*.............................................................................*", "*******************************************************************************", }; //matriz del juego //Game "Board" with the dots char av2[25][80]= { "*******************************************************************************", "* *", "* *********** *********** ***** ***** *", "* *********** *********** * * * * *", "* ** *********** * * *", "* ** ******** *********** * * * * *", "* ** *********** ***** ***** *", "* *********** *", "* *********** ********* ********* *", "* ** ********* ********* *", "* *********** ********* ********* *", "* *********** *", "* ************************************* *", "* ************************************* *", "* *********** ************************************* *", "* *********** *", "* *********** ****** *", "* ******************* ****** *", "* **** ******************* ********************* ****** *", "* ****** *** *** ****** *", "* ********* *** ***** *** ****** *", "* ********* *** ***** *** ****** *", "* *", "*******************************************************************************", }; char ce=16; int num=1; int op; int num2=1; HANDLE hOut;//Color hOut = GetStdHandle(STD_OUTPUT_HANDLE);//Color SetConsoleTextAttribute(hOut, BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY);//Color Menu(); //Menu function switch(opc){ case 1: clock_t d; d=clock(); av[1][1]=ce; if (hs<1175) { muestra(av, d); while(stop==false) { if (getch() == 224) { op = getch(); } else { op = -1; } switch (op) {//verifica que tecla se preciono y realiza el movimiento //Check which key was pressed and moves case ARR: if (comprueba(av, av2, num, num2-1)==true) {//pregunta si el movimiento es posible o no, para no salirse de los muros //Checks if the move is valid, avoiding crossing the walls av[num2][num]=' '; num2--; ce=30; av[num2][num]=ce; } break; case ABJ: if (comprueba(av, av2, num, num2+1)==true) { av[num2][num]=' '; num2++; ce=31; av[num2][num]=ce; } break; case DER: if (comprueba(av, av2, num+1, num2)==true) { av[num2][num]=' '; num++; ce=16; av[num2][num]=ce; } break; case IZQ: if (comprueba(av, av2, num-1, num2)==true){ av[num2][num]=' '; num--; ce=17; av[num2][num]=ce; } break; } muestra(av,d); } } if (hs==1175) { system("CLS"); Highscores(); } return 0; break; case 2: clock_t a; a=clock(); av2[1][1]=ce; if (hs<1175) { timemuestra(av2, a); while(stop==false) { if (getch() == 224) { op = getch(); } else { op = -1; } switch (op) {//verifica que tecla se preciono y realiza el movimiento case ARR: if (comprueba(av, av2, num, num2-1)==true) {//pregunta si el movimiento es posible o no, para no salirse de los muros av2[num2][num]=' '; num2--; ce=30; av2[num2][num]=ce; } break; case ABJ: if (comprueba(av, av2, num, num2+1)==true) { av2[num2][num]=' '; num2++; ce=31; av2[num2][num]=ce; } break; case DER: if (comprueba(av, av2, num+1, num2)==true) { av2[num2][num]=' '; num++; ce=16; av2[num2][num]=ce; } break; case IZQ: if (comprueba(av, av2, num-1, num2)==true){ av2[num2][num]=' '; num--; ce=17; av2[num2][num]=ce; } break; } timemuestra(av2, a); } } int time; time=timemuestra(av2,a); if (time>=12) { system("CLS"); Highscores(); getchar(); getchar(); } return 0; } }
int main(int argc, char *argv[]){ muestra(); }