decimal &decimal::operator=(const double &val) { std::string temp = fpt::to_string(val); convertir(temp); return *this; }
matrice partie(matrice M, char *nom, int joueur) { char coup[2]; char *ordi="l\'ordinateur"; int i, j; while ( peut_jouer(M, 1) || peut_jouer(M, 2)) { if (!peut_jouer(M, joueur)) { printf("%s ne peut pas jouer", (joueur==1)?nom:ordi); joueur=changer_joueur(joueur); } else { printf("Au tour de %s : \n", (joueur==1)?nom:ordi); do { affiche_matrice(M); printf("Rentrez un coup :\n"); fscanf(stdin, "%s", coup); if (verif_coup(coup)) { if (verif_coup(coup) == 1) { i=convertir(coup[0]); j=convertir(coup[1]); } else { j=convertir(coup[0]); i=convertir(coup[1]); } } } while (!coup_valide(M, i, j, joueur)); M=changer(M, i, j, joueur); joueur=changer_joueur(joueur); purger(); clear(); } } return M; }
int main(int argc, char *argv[]){ /* Comprobamos que se han pasado tres argumentos, si no es así finalizamos el programa e informamos del uso de éste. */ if(argc != 3) { printf("Modo de Empleo: bin2text <fichero_binario> <fichero_texto>\n"); return 1; } /* Llamamos al método que convierte el fichero de texto a binario. */ return convertir(argv[1], argv[2]); }
void leer() { FILE *fp = fopen("multi", "r"); while (!feof(fp)) { char buff[sizeof(int)]; fread(buff, sizeof(int), 1, fp); int n = convertir(buff); printf("%d\n", n); } fclose(fp); printf("\n\n\n"); }
int main() { Lista L; int i; L = NULL; for(i=1; i<=4; i++) agregarUltimo(&L, i); imprimir(L); printf("La cantidad de nodos es %d\n",contar(L)); convertir(L); imprimirLLS(L); }
void multiplicar() { FILE *fp = fopen("multi", "r"); FILE *write = fopen("multi", "r+"); while (! feof(fp)) { char buff[sizeof(int)]; fread(buff, sizeof(int), 1, fp); int num = convertir(buff); num *= 2; char *c = (char*) # fwrite(c, sizeof(int), 1, write); } fclose(fp); fclose(write); }
void reteneitor3000::on_goBoton_clicked() { if(!ui->nombreArchivo->text().isEmpty()){ if(!ui->texto->toPlainText().isEmpty()){ t = new QTimer(this); t->start(0); dialogoProgreso.show(); dialogoProgreso.setLabelText("Creando texto"); dialogoProgreso.setValue(10); QApplication::processEvents(); crearTexto(); dialogoProgreso.setLabelText("Convirtiendo texto a voz"); dialogoProgreso.setValue(20); QApplication::processEvents(); textoAvoz(); dialogoProgreso.setLabelText("Normalizando salida"); dialogoProgreso.setValue(30); QApplication::processEvents(); normalizarSalida(); dialogoProgreso.setLabelText("Mezclando las pistas"); dialogoProgreso.setValue(55); QApplication::processEvents(); mesclarPistas(); dialogoProgreso.setLabelText("Convirtiendo pista, paciencia"); dialogoProgreso.setValue(80); QApplication::processEvents(); convertir(); dialogoProgreso.setLabelText("Listo"); dialogoProgreso.setValue(100); QApplication::processEvents(); dialogoProgreso.close(); t->stop(); } else error("Debe escribir texto"); } else error("Debe seleccionar un archivo"); }
decimal &decimal::operator=(const std::string &val) { // Comprobamos que la cadena sea un numero, y la convertimos. // La funcion convertir llamará a resize(), que lanzará una // excepción si el nuevo contenido no cabe en el decimal. std::string tv = val; if(tv.empty()) tv = "0"; if(fpt::valid_number(tv, tv)) convertir(tv); else throw std::invalid_argument("La cadena no contiene un numero valido."); return *this; }
int main() { int maximo = 0; scanf("%d %d", &n, &T); for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { scanf("%d", &mapa[i][j]); suma[i][j] = suma[i][j-1] + suma[i-1][j] - suma[i-1][j-1] + mapa[i][j]; } } for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { dA[i+1][j+1] = suma[i][j] - dA[i][j]; } } for(int i=n; i>=0; i--) { for(int j=1; j<=n; j++) { dB[i][j+1] = suma[i][j] - dB[i+1][j]; } } for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { maximo = max(maximo, max(maximoCentroNegro(i, j), maximoCentroBlanco(i, j))); } } printf("%d\n", convertir(maximo)); return 0; }
string Util::sinTilde(string cadena) { string invalidos("\341\351\355\363\372\361\301\311\315\323\332\344\353\357\366\374"); string reemp; unsigned int pos = cadena.find_first_of(invalidos); while (pos != string::npos) { reemp.clear(); reemp.append(cadena.substr(0,pos)); reemp.append(convertir(cadena[pos])); reemp.append(cadena.substr(pos+1,cadena.size() - pos - 1)); cadena = reemp; pos = cadena.find_first_of(invalidos); } return cadena; }
/** * @brief funcion principal, inicializa todos los parametros y corre las funciones principales */ void main() { struct shellstr *shell; char i = 0; PCA0MD &= ~0x40; // deshabilitar el watchdog timer shell = (struct shellstr *) malloc(sizeof(struct shellstr)); shell->var = 0; // inicializar en 0 la variable auxiliar para la funcion analizar_buffer shell->conversion_active = false; if(shell == NULL) { printf("no hay lugar para shell!!\n"); while(1); } //inicializa el buffer de valores estaticos en 0 for (i=0 ; i<TAM_SINGLE ; i++) shell->buffer_adc_count[i]=0; //inicializa la bandera de sleep en 0 f_sleep = 0; iniciar_sysclock(); iniciar_puertos(); iniciar_osc_externo(); iniciar_UART(); iniciar_PCA(); iniciar_ADC(); iniciar_timer0(); iniciar_timer2(); iniciar_contadorRPM(); // iniciar_timer3(); shell->stop_conf = 1; while (1) { // comienza ciclo infinito hasta que se de la orden de parar la configuracion while(shell->stop_conf == 1) { restart(shell); // reinicia los arreglos de obtencion de comandos obtener_entrada(shell); if(shell->report != 0) // si hay un error, el comando no se analiza { reportar(shell); } else { analizar(shell); reportar(shell); // si hay un error en el analisis, hay que reportarlo } } // se inicializa el buffer temporal for(i = 0; i < TAM_SINGLE; i++) { shell->buffer_adc[i] = shell->buffer_adc_count[i]; } AD0INT = 0; // se inicializa en 0 el bit de conversion completa del ADC ADC0MUX = 0x08; // el primer pin a analizar es el pin 0 en modo single-ended ADC0MD = 0x83; // Habilitar conversion en modo continuo EIE1 |= 0x08; // Habilitar interrupciones del ADC EA = 1; // habilitar interrupciones globales // ES0 = 1; while(1) { // empezar_adc(); shell->conversion_active = true; ES0 = 1; // habilitar interrupcion de UART //monitoriza entrada serial if (f_UART) { int recibido = (int)SBUF0; f_UART = false; //printf("STOP. message: '%c'\n", (char)recibido); if(recibido == 112) // 112 es 'p' en ascii { // printf("stillOn\n"); shell->conversion_active = false; refresh_watchDog(); shell->report = 501; // stillOn successful reportar(shell); } else if(recibido == 115) //115 es 's' en ascii { ADC0MD = 0x00; // conversion inhabilitada EA = 0; // inhabilitar interrupciones globales shell->stop_conf = 1; shell->report = 500; // stop succesful reportar(shell); break; } } ES0 = 0; // deshabilitar interrupcion de UART if(f_dato_convertido) { f_dato_convertido = false; dato_a_enviar = convertir(); if(analizar_buffer(shell)) { enviar_dato(&dato_a_enviar); // mostrar_config_actual(shell); } // LED = ~LED; cambiar_pin(); } } } }