void loop() { inicio(); Menu(); }
void ListaLigadaObjetosGraficos::apaga_tudo() { inicio(); while (!vazia()) del_atual(); }
void Menu() { char opcion = Serial.read(); switch (opcion ) { case 'a': while(opcion=='a') { Inten1(); Menu(); } break; case 'b': while(opcion=='b') { inicio(); Menu(); } break; } }
int main(int argc, const char **argv){ srand(time(NULL)); srand48(time(NULL)); int ancho, alto; Nave principal[PERSONAJE]; Nave secundaria[ENEMIGO]; inicio(principal, secundaria, ancho, alto); initscr(); getmaxyx(stdscr, ancho, alto); curs_set(0); while(getch() != 27){ naves_ataquen(secundaria, principal); dibuja(principal, secundaria, ancho, alto); } curs_set(1); endwin(); return EXIT_SUCCESS; }
/** * muestra el menu y direcciona a las opciones */ int MainCliente::menu(){ opt = 0; while (opt != OPT_SALIR){ #ifndef FAKE_DEBUG_CLIENTE inicio(); #endif conectarYEjecutar(); } return 0; }
void TotalSincrono::Valor(QString valor, QString Log) { if (valor == "Quitar") { CierreTotal = 1; } if (Log == "S") log = "S"; else log = "N"; inicio(); }
OperacionBase::OperacionBase(QObject *parent) : QObject(parent) { /*El QVariantMap tiene que estar formado por los datos de registroCnp o registroMet o registroOrto mas los datos de TableViewCoordinates, directorio de salida nombre de salida etc*/ registro=QVariantMap(); contador=0; //Conexiones flujo.setDevice(&proceso); connect(&proceso,SIGNAL(started()),this,SLOT(inicio())); connect(&proceso,SIGNAL(finished(int)),this,SLOT(fin(int))); connect(&proceso,SIGNAL(readyRead()),this,SLOT(datosSalida())); }
int main(int argc, const char **argv){ int resultado=0; int ancho=0; int buffer=0; struct TMatriz matriz; inicio (&matriz); // Preguntar al usuario. do{ __fpurge(stdin); printf ("Cuantas filas quiere que tenga su matriz?\n"); scanf ("%i", &matriz.filas); printf ("Cuantas columnas quiere que tenga su matriz?\n"); scanf ("%i", &matriz.col); }while(matriz.filas == 0 && matriz.col == 0); // reservar espacio para a matriz.a = (int *) realloc (matriz.a, ((matriz.filas)*(matriz.col)*sizeof(int))); ancho = matriz.col; for (int f=0; f<matriz.filas; f++) for (int c=0; c<matriz.col; c++){ printf("(%i, %i)", f+1, c+1); scanf(" %i", &buffer); set(matriz.a, f, ancho, c, buffer); } printf ("Ahora imprimiremos tu matriz\n"); for (int f=0; f<matriz.filas; f++){ for(int c=0; c<matriz.col; c++){ resultado = get(matriz.a, f, ancho, c); printf ("%4i", resultado); } printf ("\n"); } // Liberar espacio para a free(matriz.a); return EXIT_SUCCESS; }
//Reset do jogo void Board::reset() { vetorSnakeX.clear(); vetorSnakeY.clear(); QSound botaoSound("Media/Windows Navigation Start.wav"); botaoSound.play(); tempo.stop(); pause = false; score = 0; vida = 0; end == 'i'; ctrlFim == false; tamSnake = 1; run = false; emit sinalReset(); inicio(); }
bool lista::borrar_Noticia (Tcadena1 cad){ char cad2[MaxCadRef]; poner_fin(); while(!inicio()){ retroceder(); if(elemento[pi].Vacia()) return false; TipoDato dat; elemento[pi].Poner_Inicio(); while(elemento[pi].Fin()==false){ elemento[pi].Consultar(dat); if(dat.Comparar(cad)==0){; elemento[pi].Borrar(); return true;} elemento[pi].Avanzar(); } } return false; }
int main(){ setlocale(LC_ALL, "Portuguese"); FILE *arq; char** mat; char ch; char s[200], aux[50]; int linhas=0, colunas=0, i, j; arq = fopen("Cliente.txt", "r"); if (arq==NULL){ printf ("Erro.\n"); } inicio(arq, mat, ch, s, aux); fclose(arq); return 0; }
/* Copia: */ void copia(PCola destino,PCola origen){ PNodoCola temp; if (tamano(origen)==0) /* Origen no debe estar vacio*/ return; while((tamano(destino))>0) /* Borrado de la cola destino */ { extrae(destino); } temp = origen->iterador; /* Almaceno temporalmente el iterador */ inicio(origen); inserta(destino,examina(origen)); while (avanza(origen)) /* Recorro la cola origen,y la voy insertando */ { inserta(destino,examina(origen)); /* Si he llegado al elemento que estaba señalado,fijo el iterador * en el final de destino */ if (origen->iterador==temp) fin(destino); } origen->iterador=temp; /* Recolocar el iterador en origen */ }
const BOLEANO ListaLigadaObjetosGraficos::del_atual() { if (!vazia()) { if (this->c_atual->ante) this->c_atual->ante->prox = this->c_atual->prox; else this->c_pri = this->c_atual->prox; if (this->c_atual->prox) this->c_atual->prox->ante = this->c_atual->ante; else this->c_ult = this->c_atual->ante; delete this->c_atual; inicio(); return VERDADEIRO; } else return FALSO; }
int main(void) { int x = 0; no *lista=(no*) malloc(sizeof(no)); int v2[10] = { 2, -3, 1, 89, 99, 88, -3, 19, 35, 11 }; //arbitrário ;) inicio(lista); for ( x = 0; x < 10; x++) { insere(lista, v2[x]); } imprime(lista); for ( x = 0; x<10; x ++) { busca(lista, v2[x]); } for ( x = 0; x<10; x ++) { remover(lista); } //imprime(lista); return 0; }
void MainWindow::on_pushButton_clicked() { AStar<Node> pathfinder; Node inicio(0, 0); Node fin(19, 19); inicio.setMap(this->ui->tableWidget); fin.setMap(this->ui->tableWidget); pathfinder.setBaseNode(inicio); pathfinder.setGoalNode(fin); cout << "Status: " << pathfinder.run() << endl; cout << "Pasos: " << pathfinder.getSteps() << endl; //pathfinder.showSolution(); list<Node*> solution = pathfinder.solution(); list<Node*>::iterator it; for (it = solution.begin(); it != solution.end(); it++) { ui->tableWidget->item((*it)->y, (*it)->x)->setBackgroundColor(QColor(255, 0, 0)); } }
void main() { char op; inicializa(); stars(); menu(); op=toupper(getch()); switch(op) { case 'I': inicio(); break; case 'D': outtextxy(300,300, "DIFICULTAD"); break; case 'C': outtextxy(300,300, "CREDITOS"); break; case 'S': outtextxy(300,300, "SALIR"); break; } getch(); }
main(void) { char *c; int fd, sz, i; c = inicio(); fd = open("input.in", O_RDONLY); if (fd < 0) { perror("r1"); exit(1); } sz = read(fd, c, 10); c[sz] = '\0'; //<-------------- printf("Hemos abierto input.in, y hemos llamado a read(%d, c, 10).\n", fd); printf("read ha leido %d bytes.\n", sz); printf("Estos bytes son los siguientes: %s\n", c); i = lseek(fd, 0, SEEK_CUR); printf("lseek(%d, 0, SEEK_CUR) retorna que el desplazamiento actual del archivo es %d\n\n", fd, i); printf("Ahora, buscamos el principio del archivo y llamamos a read(%d, c, 10)\n",fd); lseek(fd, 0, SEEK_SET); sz = read(fd, c, 10); c[sz] = '\0'; //<-------------- printf("La lectura retorna los siguientes bytes: %s\n", c); printf("Ahora, se ejecuta lseek(%d, -6, SEEK_END). y retorna %d\n",fd, (int) lseek(fd, -6, SEEK_END)); printf("Si ejecutamos read(%d, c, 10), obtendremos los siguientes bytes: ", fd); sz = read(fd, c, 10); c[sz] = '\0'; //<-------------- printf("Finalmente, ejecutamos lseek(%d, -1, SEEK_SET). Esto retorna -1.\n", fd); printf("perror() nos dice por que:\n"); fflush(stdout); i = lseek(fd, 1, SEEK_SET); perror("l1"); }
void main(int argc, char** argv) { ////home//clnx//Escritorio//pp a1// //printf("\n***** PROYECTO FASE 1 MENEJO E IMPLEMENTACION DE ARCHIVOS *****\n \n"); //printf("tamaño %i\n",sizeof(fatRootFolder)); //printf("tamaño %i\n",sizeof(mbr)); //system("gedit //home//clnx//Escritorio//hola.txt"); inicio(); //archivoENLAZADO(); /*int i,r,n; i=250; n=i/100; r=i%100; printf("%i\n",n); printf("%i\n",r);*/ /*char *cads,nombre[10],nom[10],ext[5]; int j=0; strcpy(nombre,"archivo 1.txt"); cads=strtok(nombre,"."); for(j=0;cads;j++){ if(j==0){ strcpy(nom,cads); }else{ strcpy(ext,cads); } cads=strtok(0,"."); } printf("%s\n",nom); printf("%s\n",ext);*/ /*char path[150]="/home/clnx/Escritorio/pp a1/archivo.txt"; Lista *l; l=malloc(sizeof(Lista)); divPath(l,path); recLista(l);*/ }
int main() { FILE *cli,*art; char *nomarchcli="c:\\clientes.dat"; char *nomarchart="c:\\articulos.dat"; system("cls"); if((cli=fopen(nomarchcli,"wb+"))==NULL) exit(error(nomarchcli)); p("\nEl archivo %s ha sido cargado!!",nomarchcli); if((art=fopen(nomarchart,"wb+"))==NULL) exit(error(nomarchart)); p("\nEl archivo %s ha sido cargado!!",nomarchart); tecla(); inicio(cli,art); system("cls"); ingresar(cli,art); mostrar(cli,art); linea(80); tecla(); //lo muestro fclose(cli);fclose(art); return(0); }
void correrwallp(void) { ALLEGRO_TIMER *timer = NULL; ALLEGRO_EVENT_QUEUE *queue=NULL; ALLEGRO_BITMAP *fondo=NULL, *icons[4]; boton items[4]; void (*p2buttonf[4])(void); queue = al_create_event_queue(); timer = al_create_timer(1.0/FPS); //genero un timer para trabajar en 60 fps bool redraw=false; fondo=al_load_bitmap("wallfondo.png"); //wally1 icons[0]=al_load_bitmap("wally1.png"); botones(&items[0],30,70, 150, 200); p2buttonf[0]=cambiarfondo1; //wally2 icons[1]=al_load_bitmap("wally2.png"); botones(&items[1],230,70, 150, 200); p2buttonf[1]=cambiarfondo2; //wally3 icons[2]=al_load_bitmap("wally3.png"); botones(&items[2],30,330, 150, 200); p2buttonf[2]=cambiarfondo3; //wally4 icons[3]=al_load_bitmap("wally4.png"); botones(&items[3],230,330, 150, 200); p2buttonf[3]=cambiarfondo4; //register events al_register_event_source(queue, al_get_display_event_source(display)); al_register_event_source(queue, al_get_keyboard_event_source()); al_register_event_source(queue, al_get_mouse_event_source()); al_register_event_source(queue, al_get_timer_event_source(timer)); //timer starts al_start_timer(timer); while(!doexit && !exitmenu) // loop { ALLEGRO_EVENT ev; al_wait_for_event(queue, &ev); // espero a timer, salida o keyboard if(ev.type == ALLEGRO_EVENT_TIMER) redraw = true; // si es el timer de refresco, redibujo salio(ev); inicio(ev); presionobotones(ev, items, p2buttonf,4); if(redraw) { // si hay que redibujar al_draw_bitmap(fondo, 0, OFFSETUP, 0); drawbotones(items, icons,4); redraw=false; al_flip_display(); //flipeo } } al_destroy_event_queue(queue); al_destroy_bitmap(fondo); al_destroy_bitmap(icons[0]); al_destroy_bitmap(icons[1]); al_destroy_bitmap(icons[2]); al_destroy_bitmap(icons[3]); al_destroy_timer(timer); exitmenu=false; }
void corrermusica(void){ const int CANTICANCIONES=5; ALLEGRO_TIMER *timer = NULL; ALLEGRO_EVENT_QUEUE *queue=NULL; ALLEGRO_BITMAP *icons[CANTICANCIONES]; boton items[CANTICANCIONES]; void (*p2buttonf[CANTICANCIONES])(void); ALLEGRO_FONT *font=NULL; queue = al_create_event_queue(); timer = al_create_timer(1.0/FPS); //genero un timer para trabajar en 60 fps bool redraw=false; //pajaros icons[0]=al_load_bitmap("pajaros.png"); botones(&items[0],30,70, 150, 200); p2buttonf[0]=pajaros; //clorofila icons[1]=al_load_bitmap("clorofila.png"); botones(&items[1],230,70, 150, 200); p2buttonf[1]=clorofila; //brisa icons[2]=al_load_bitmap("brisa.png"); botones(&items[2],30,330, 150, 200); p2buttonf[2]=brisa; //alfred icons[3]=al_load_bitmap("graciasalfred.png"); botones(&items[3],230,330, 150, 200); p2buttonf[3]=graciasalfred; //mute icons[4]=al_load_bitmap("mute.png"); botones(&items[4],340,OFFSETDOWN-70, 64, 64); p2buttonf[4]=mute; //font font=al_load_font("font.ttf",30,0); //register events al_register_event_source(queue, al_get_display_event_source(display)); al_register_event_source(queue, al_get_mouse_event_source()); al_register_event_source(queue, al_get_timer_event_source(timer)); //timer starts al_start_timer(timer); while(!doexit && !exitmenu) // loop { ALLEGRO_EVENT ev; al_wait_for_event(queue, &ev); // espero a timer, salida o keyboard if(ev.type == ALLEGRO_EVENT_TIMER) redraw = true; // si es el timer de refresco, redibujo salio(ev); inicio(ev); presionobotones(ev, items, p2buttonf,CANTICANCIONES); if(redraw && !exitmenu){ // si hay que redibujar drawfondo(); al_draw_text(font, al_map_rgb(171,130,255), 10, OFFSETDOWN-55, ALLEGRO_ALIGN_LEFT,"Musica por Motoneta"); drawbotones(items, icons,CANTICANCIONES); redraw=false; al_flip_display(); //flipeo } } al_destroy_event_queue(queue); al_destroy_timer(timer); al_destroy_bitmap(icons[0]); al_destroy_bitmap(icons[1]); al_destroy_bitmap(icons[2]); al_destroy_bitmap(icons[3]); exitmenu=false; }
void cmdInicio(int modo){ inicio(); pon_tortuga(400,300,0); if(modo)readkey(); }
Window::Window(QWidget *parent) { chek = false; quadro = new Board(0); if(quadro == NULL){ qDebug() << "quadro Falhou!"; chek = true; }else{ qDebug() << "quadro Sucesso!"; } layout = new QGridLayout; if(layout == NULL){ qDebug() << "layout Falhou!"; chek = true; }else{ qDebug() << "layout Sucesso!"; } file = new QFile(); if(file == NULL){ qDebug() << "file Falhou!"; chek = true; }else{ qDebug() << "file Sucesso!"; } lcdLevel = new QLCDNumber(); if(lcdLevel == NULL){ qDebug() << "lcdLevel Falhou!"; chek = true; }else{ qDebug() << "lcdLevel Sucesso!"; } lcdScore = new QLCDNumber(); if(lcdScore == NULL){ qDebug() << "lcdScore Falhou!"; chek = true; }else{ qDebug() << "lcdScore Sucesso!"; } labelLevel = new QLabel("Level:",this); if(labelLevel == NULL){ qDebug() << "labelLevel Falhou!"; chek = true; }else{ qDebug() << "labelLevel Sucesso!"; } labelScore = new QLabel("Score:",this); if(labelScore == NULL){ qDebug() << "labelScore Falhou!"; chek = true; }else{ qDebug() << "labelScore Sucesso!"; } labelLife = new QLabel("Vida:",this); if(labelLife == NULL){ qDebug() << "labelLife Falhou!"; chek = true; }else{ qDebug() << "labelLife Sucesso!"; } botaoStart = new QPushButton("Start"); if(botaoStart == NULL){ qDebug() << "botaoStart Falhou!"; chek = true; }else{ qDebug() << "botaoStart Sucesso!"; } botaoPause = new QPushButton("Pause"); if(botaoPause == NULL){ qDebug() << "botaoPause Falhou!"; chek = true; }else{ qDebug() << "botaoPause Sucesso!"; } botaoReset = new QPushButton("Reset"); if(botaoReset == NULL){ qDebug() << "botaoReset Falhou!"; chek = true; }else{ qDebug() << "botaoReset Sucesso!"; } menuBar = new QMenuBar; if(menuBar == NULL){ qDebug() << "menuBar Falhou!"; chek = true; }else{ qDebug() << "menuBar Sucesso!"; } fileMenu = new QMenu(tr("&File"), this); if(fileMenu == NULL){ qDebug() << "fileMenu Falhou!"; chek = true; }else{ qDebug() << "fileMenu Sucesso!"; } barraProgresso = new QProgressBar(); if(barraProgresso == NULL){ qDebug() << "barraProgresso Falhou!"; chek = true; }else{ qDebug() << "barraProgresso Sucesso!"; } barraVida = new QProgressBar(); if(barraVida == NULL){ qDebug() << "barraVida Falhou!"; chek = true; }else{ qDebug() << "barraVida Sucesso!"; } tempo = new QTimer(this); if(tempo == NULL){ qDebug() << "tempo Falhou!"; chek = true; }else{ qDebug() << "tempo Sucesso!"; } contadorBarra = 1; baseScore =5; tamInicioBarra = 0; tamFimBarra = baseScore; barraVida->setMaximum(3); contadorVida = 0; aboutAct = new QAction(tr("&About"), this); if(aboutAct == NULL){ qDebug() << "aboutAct Falhou!"; chek = true; }else{ qDebug() << "aboutAct Sucesso!"; } aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); connect(botaoStart, SIGNAL(clicked()), quadro, SLOT(inicio())); connect(botaoPause, SIGNAL(clicked()), quadro, SLOT(pausa())); connect(botaoReset, SIGNAL(clicked()), quadro, SLOT(reset())); connect(quadro, SIGNAL(nivelDificuldade(int)), lcdLevel, SLOT(display(int))); connect(quadro, SIGNAL(pontosGanho(int)), lcdScore, SLOT(display(int))); connect(quadro, SIGNAL(barra_Progresso()), this, SLOT(barraDeProgresso())); connect(quadro, SIGNAL(barra_Vida()), this, SLOT(barraDeVida())); connect(quadro, SIGNAL(sinalReset()), this, SLOT(resetJogo())); connect(quadro, SIGNAL(salvaScore()), this, SLOT(save())); this->resize(304,400); this->setMaximumSize(304,400); quadro->setMinimumSize(104,200); quadro->setMaximumSize(304,400); createMenu(); layout->addWidget(menuBar); layout->addWidget(quadro,3,0,10,3); layout->addWidget(labelLevel, 3, 4); layout->addWidget(lcdLevel,4,4); layout->addWidget(labelScore, 5,4); layout->addWidget(lcdScore,6,4); layout->addWidget(botaoStart,7,4); layout->addWidget(botaoPause,8,4); layout->addWidget(botaoReset,9,4); layout->addWidget(barraProgresso); layout->addWidget(labelLife); layout->addWidget(barraVida); this->setLayout(layout); this->show(); if(chek == true) { falhaCritica(); } }