void inserer(const char * entite, const char type, const char nature, const unsigned short taille){ liste *q; liste * position = rechercher(entite); if(position==NULL){ // Nouvelle entité if(tete==NULL){ p=(liste*)malloc(sizeof(liste)); strcpy(p->elm.nom,entite); // Insérer le nom de l'entité p->elm.type = type; // Insérer le type de l'entité p->elm.nature = nature; // Insérer la nature de l'entité p->elm.taille = taille; // Insérer la taille de l'entité tete=p; p->svt=NULL; } else { q=(liste*)malloc(sizeof(liste)); p->svt=q; strcpy(q->elm.nom,entite); // Insérer le nom de l'entité q->elm.type = type; // Insérer le type de l'entité q->elm.nature = nature; // Insérer la nature de l'entité q->elm.taille = taille; // Insérer la taille de l'entité q->svt=NULL; p=q; } // Insérer l'entité } }
// true si pas d'erreur dans l'analyse des entete, si multipart alors bondary != NULL bool annalyser_Entete(regex_t r, char* ext, char* boundary){ char buff_ans[128]; bool multipart=false; const int n_matches= 5; regmatch_t m[n_matches]; while(strcmp(fgets(buff_ans, 128, fsock), "\r\n")!=0){ if(strncmp(buff_ans, "-ERR", 4) == 0){ printf("%s", buff_ans); return false; } int match= regexec(&r, buff_ans, n_matches, m, 0); if(match == 0){ char* type=NULL; type=strndup(buff_ans + (int) m[2].rm_so, m[2].rm_eo - m[2].rm_so ); if(strncasecmp(type, "multipart", strlen("multipart")) == 0){ multipart=true; char * tmpbound= (char*) malloc(sizeof(char) * LINELENGTH - 4); tmpbound=strndup(buff_ans + (int) m[4].rm_so, m[4].rm_eo - m[4].rm_so); strcpy(boundary, tmpbound); free(tmpbound); } else{ char* tmp= (char*) malloc(sizeof(char) * MAXEXTLENGTH); tmp= rechercher(type); strcpy(ext, tmp); free(type); } } } return multipart; }
void PAIRE(){ //Paire : string : Valeur if(rechercher(liste,sym_cour.nom)==0){ liste = ajouter_string(liste,sym_cour.nom);} else Error(DOUBLE_ERR); Test_Symbole(STRING_TOKEN,STRING_ERR); Test_Symbole(DEUXP_TOKEN,DEUXP_ERR); VALEUR(); }
int main(void) { int choix ; int nb ; Liste ma_liste ; init(); // initialisations (des structures de donnees utilisees pour la // gestion de la memoire) ma_liste = creer_liste_vide() ; menu(); choix = lire_entier() ; while (choix != 0) { switch(choix) { case 1 : ma_liste = creer_liste_vide() ; break; case 2 : afficher_chaine("nombre a inserer ? "); nb = lire_entier(); ma_liste = inserer_tete(ma_liste, nb); break ; case 3 : afficher_chaine("nombre a rechercher ? "); nb = lire_entier(); if(rechercher(ma_liste, nb) !=0) afficher_chaine (" present!\n"); else afficher_chaine(" absent!\n"); break; case 4 : afficher_liste(ma_liste); break ; case 5: afficher_liste_inverse(ma_liste); break ; case 6: ma_liste = supprimer_tete(ma_liste); break ; case 7: ma_liste = supprimer_queue(ma_liste); break ; } menu(); choix = lire_entier() ; } return(0); }
/* * Stocke le couple (identifiant, ensemble) dans la pile. * Une recherche d'un couple avec le même identifiant a lieu. * Si un tel couple existe, mise à jour de l'ensemble associé à cet identifiant. * Sinon ajout dans la pile. */ void stocker (struct Pile * pile, unsigned int identifiant, unsigned int ensemble) { struct ElementPile * element = NULL; if ((element = rechercher(pile, identifiant)) != NULL) { element->ensemble = ensemble; } else { empiler(pile, identifiant, ensemble); } }
/** * @brief Constructeur * * Ce constructeur initialise toutes les fonctions de l'Interface Graphique de cette fenêtre : créer et organiser les * objets graphiques, et les connecter avec les bons slots. */ UVWindow::UVWindow() { setWindowTitle("UTProfiler"); mainlayout = new QVBoxLayout(); hlayout1 = new QHBoxLayout(); pbretour = new QPushButton("Retour"); lcode = new QLabel("Code : "); lecode = new QLineEdit(); pbrechercher = new QPushButton("Rechercher"); lresponsable = new QLabel("Responsable : "); leresponsable = new QLineEdit(); hlayout1->addWidget(pbretour); hlayout1->addWidget(lcode); hlayout1->addWidget(lecode); hlayout1->addWidget(pbrechercher); hlayout1->addWidget(lresponsable); hlayout1->addWidget(leresponsable); hlayout2 = new QHBoxLayout(); tedescription = new QTextEdit(); vlayout21 = new QVBoxLayout(); hlayout211 = new QHBoxLayout(); lprintemps = new QLabel("Printemps : "); cbprintemps = new QCheckBox(); hlayout211->addWidget(lprintemps); hlayout211->addWidget(cbprintemps); hlayout212 = new QHBoxLayout(); lautomne = new QLabel("Automne : "); cbautomne = new QCheckBox(); hlayout212->addWidget(lautomne); hlayout212->addWidget(cbautomne); vlayout21->addLayout(hlayout211); vlayout21->addLayout(hlayout212); hlayout2->addWidget(tedescription); hlayout2->addLayout(vlayout21); hlayout3 = new QHBoxLayout(); lcs = new QLabel("CS : "); lecs = new QLineEdit(); ltm = new QLabel("TM : "); letm = new QLineEdit(); ltsh = new QLabel("TSH :"); letsh = new QLineEdit(); lsp = new QLabel("SP : "); lesp = new QLineEdit(); hlayout3->addWidget(lcs); hlayout3->addWidget(lecs); hlayout3->addWidget(ltm); hlayout3->addWidget(letm); hlayout3->addWidget(ltsh); hlayout3->addWidget(letsh); hlayout3->addWidget(lsp); hlayout3->addWidget(lesp); hlayout4 = new QHBoxLayout(); ltc = new QLabel("TC : "); cbtc = new QCheckBox(); lhutech = new QLabel("HUTECH : "); cbhutech = new QCheckBox(); lgb = new QLabel("GB : "); cbgb = new QCheckBox(); lgi = new QLabel("GI : "); cbgi = new QCheckBox(); lgm = new QLabel("GM : "); cbgm = new QCheckBox(); lgp = new QLabel("GP : "); cbgp = new QCheckBox(); lgsm = new QLabel("GSM : "); cbgsm = new QCheckBox(); lgsu = new QLabel("GSU : "); cbgsu = new QCheckBox(); hlayout4->addWidget(ltc); hlayout4->addWidget(cbtc); hlayout4->addWidget(lhutech); hlayout4->addWidget(cbhutech); hlayout4->addWidget(lgb); hlayout4->addWidget(cbgb); hlayout4->addWidget(lgi); hlayout4->addWidget(cbgi); hlayout4->addWidget(lgm); hlayout4->addWidget(cbgm); hlayout4->addWidget(lgp); hlayout4->addWidget(cbgp); hlayout4->addWidget(lgsm); hlayout4->addWidget(cbgsm); hlayout4->addWidget(lgsu); hlayout4->addWidget(cbgsu); hlayout5 = new QHBoxLayout(); pbnouveau = new QPushButton("Nouveau"); pbsupprimer = new QPushButton("Supprimer"); pbsauver = new QPushButton("Sauver"); hlayout5->addWidget(pbnouveau); hlayout5->addWidget(pbsupprimer); hlayout5->addWidget(pbsauver); mainlayout->addLayout(hlayout1); mainlayout->addLayout(hlayout2); mainlayout->addLayout(hlayout3); mainlayout->addLayout(hlayout4); mainlayout->addLayout(hlayout5); this->setLayout(mainlayout); QObject::connect(pbretour,SIGNAL(clicked()),this,SLOT(close())); QObject::connect(pbsupprimer,SIGNAL(clicked()),this,SLOT(supprimer())); QObject::connect(pbnouveau,SIGNAL(clicked()),this,SLOT(nouveau())); QObject::connect(lecode,SIGNAL(returnPressed()),this,SLOT(rechercher())); QObject::connect(pbrechercher,SIGNAL(clicked()),this,SLOT(rechercher())); QObject::connect(pbsauver,SIGNAL(clicked()),this,SLOT(sauver())); QObject::connect(leresponsable,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable())); QObject::connect(tedescription,SIGNAL(textChanged()),this,SLOT(pbsauverEnable())); QObject::connect(lecs,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable())); QObject::connect(letm,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable())); QObject::connect(letsh,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable())); QObject::connect(lesp,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable())); QObject::connect(cbprintemps,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbautomne,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbtc,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbhutech,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbgb,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbgi,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbgm,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbgp,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbgsm,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); QObject::connect(cbgsu,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable())); }
/** * @brief Résout un puzzle * @param[in,out] p le puzzle à résoudre * @param[in] t le damier initial * @param[in,out] os flux de sortie */ void jouer(Puzzle& p, const Tab2D& t, std::ostream& os) { Etat etatInitial; Etat etatCourant; Tab2D damierFinal; Etat etatDerive; double tempsDebutRecherche = getTime(); but(damierFinal, t.nbL, t.nbC); initialiser(etatInitial.damier, t.nbL, t.nbC); etatInitial.mouvement = FIXE; etatInitial.precedent = 0; etatInitial.g = 0; //Copie du damier inititial dans etatInitial for (unsigned int l = 0; l < t.nbL; ++l) { for (unsigned int c = 0; c < t.nbC; ++c) { etatInitial.damier.tab[l][c] = t.tab[l][c]; } } etatInitial.h = manhattan(etatInitial.damier, damierFinal); initialiser(etatDerive.damier, t.nbL, t.nbC); inserer(p.lEAE, 0, etatInitial); //étatInitial dans LEAE bool solutionTrouvee = false; bool mvtPossible; unsigned int pos; while (p.lEAE.nb != 0) { pos = minimal(p.lEAE); etatCourant = lire(p.lEAE, pos); //on prend le 1er état à explorer //insérer étatCourant dans LEE inserer(p.lEE, longueur(p.lEE), etatCourant); supprimer(p.lEAE, pos); //supprimer étatCourant de LEAE if (etatCourant.h == 0) { // le damier de étatCourant est le damier but solutionTrouvee = true; break; //sortir de la boucle while } /*pour_tout (mouvement possible associé à étatCourant) mouvement possible relatif à damier de étatCourant (etatCourant.damier) ordre d'exploration (obligatoire) NORD, EST, SUD, OUEST */ //initialiser un étatDérivé // d'après le mouvement for(int m = OUEST; m >= NORD; --m) { mvtPossible = deriver(etatCourant, (Mouvement) m, etatDerive); if (mvtPossible && !rechercher(etatDerive, p.lEAE)\ && !rechercher(etatDerive, p.lEE)) { etatDerive.precedent = longueur(p.lEE) - 1; etatDerive.h = manhattan(etatDerive.damier, damierFinal); etatDerive.g = etatCourant.g + 1; //insérer étatDérivé dans LEAE inserer(p.lEAE, longueur(p.lEAE), etatDerive); } } } double tempsFinRecherche = getTime(); cout << "Durée de recherche : " << tempsFinRecherche - tempsDebutRecherche <<" seconde(s)."<< endl; if (solutionTrouvee) { Pile sol; Etat etatSol; initialiser(sol, 3, 2); initialiser(etatSol.damier, t.nbL, t.nbC); //Stockage de la solution etatSol = lire(p.lEE, longueur(p.lEE)-1); empiler(sol, etatSol); while (etatSol.precedent != 0) { etatSol = lire(p.lEE, etatSol.precedent); empiler(sol, etatSol); } empiler(sol, etatInitial); //Affichage de la solution os << "Damier : " << t.nbL << " lignes " << t.nbC << " colonnes" << endl; os << "Solution en " << sol.sommet << " mouvements" << endl; while (!estVide(sol)) { afficher(sommet(sol), os); os << endl; depiler(sol); } detruire(sol); detruire(etatSol.damier); } else { os << "Solution non trouvée" << endl; } detruire(etatInitial.damier); detruire(etatCourant.damier); detruire(etatDerive.damier); detruire(damierFinal); }
Navigateur::Navigateur(): m_PointeurChargerRafraichir(new QToolButton(this)), m_barAddress (new QLineEdit(this)), m_barRecherche (new QLineEdit(this)), m_tabWidget (new QTabWidget(this->centralWidget())), m_currWebView (new QWebView(this->centralWidget())), m_pageAccueil ("http://www.globo.com"), m_rechercheDefault("Google") { // 1. creer Fenetre Principale this->resize(800, 600); this->setWindowTitle("zNavigo"); this->setWindowIcon(QIcon("images/icon-browser.png")); this->setAnimated(true); creerMenu(); // 2. creer menus creerActions(); // 3. creer actions creerToolBars(); // 4. creer barre d'outils creerWebView(); // 5. creer tabBar avec webView creerStatusBar(); // 6. creer barre de status // 7. Aller a la page d'acueil this->aller(m_pageAccueil); /// [CONNECTIONS] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Faire la connection de la barre d'address pour changer la page QObject::connect(m_barAddress, SIGNAL(returnPressed()), this, SLOT(allerAPageAddress())); QObject::connect(m_currWebView, SIGNAL(loadProgress(int)), m_statusProgress, SLOT(setValue(int))); QObject::connect(m_currWebView, SIGNAL(loadStarted()), this, SLOT(debutChargement())); QObject::connect(m_currWebView, SIGNAL(loadFinished(bool)), this, SLOT(finChargement(bool))); // [MENU FICHIER]__________________________________________________________ // Faire la connection pour ouvrir un fichier html QObject::connect(m_actionOuvrir, SIGNAL(triggered()), this, SLOT(ouvrirHtml())); // Faire la connection pour ouvrir un lien QObject::connect(m_actionOuvrirLien, SIGNAL(triggered()), this, SLOT(ouvrirLien())); // Faire la connection pour sauvegarder page QObject::connect(m_actionSauvegarder, SIGNAL(triggered()), this, SLOT(sauvegarderPage())); // Faire la connection pour sauvegarder page sous QObject::connect(m_actionSauvegarderSous, SIGNAL(triggered()), this, SLOT(sauvegarderPageSous())); // Faire la connection pour imprimer page QObject::connect(m_actionImprimer, SIGNAL(triggered()), this, SLOT(imprimerPage())); // Faire la connection pour Quitter l'app QObject::connect(m_actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit())); // ________________________________________________________________________ // [MENU EDITION]__________________________________________________________ QObject::connect(m_actionRechercher, SIGNAL(triggered()), this, SLOT(rechercher())); // ________________________________________________________________________ // [MENU AFFICHAGE]________________________________________________________ QObject::connect(m_actionArreterChargement, SIGNAL(triggered()), m_currWebView, SLOT(stop())); QObject::connect(m_actionRafraichir, SIGNAL(triggered()), m_currWebView, SLOT(reload())); // ________________________________________________________________________ // [MENU HISTORIQUE]________________________________________________________ QObject::connect(m_actionArriere, SIGNAL(triggered()), m_currWebView, SLOT(back())); QObject::connect(m_actionEnAvant, SIGNAL(triggered()), m_currWebView, SLOT(forward())); // ________________________________________________________________________ /// [END CONNECTIONS] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 9. keep looping }