Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define TAILLE_MAX 150
- typedef struct Motherboard{
- char marque[TAILLE_MAX];
- char modele[TAILLE_MAX];
- char socket_proc[TAILLE_MAX];
- char nbr_socket[TAILLE_MAX];
- char nbr_ram[TAILLE_MAX];
- char ver_ram[TAILLE_MAX];
- char nbr_pci[TAILLE_MAX];
- char nbr_ide[TAILLE_MAX];
- char nbr_sata[TAILLE_MAX];
- char nbr_usb[TAILLE_MAX];
- char nbr_vga[TAILLE_MAX];
- char nbr_reseau[TAILLE_MAX];
- char format[TAILLE_MAX];
- char usp[TAILLE_MAX];
- char fiab[TAILLE_MAX];
- char restrict[TAILLE_MAX];
- char prix[TAILLE_MAX];
- char conso_elec[TAILLE_MAX];
- char overclock[TAILLE_MAX];
- }Motherboard;
- typedef struct Graphics{
- char marque[TAILLE_MAX];//Marque
- char modele[TAILLE_MAX];//Modèle
- char nbr_vga[TAILLE_MAX];//Nombre de ports VGA
- char nbr_dvi[TAILLE_MAX];//Nombre de ports DVI
- char nbr_hdmi[TAILLE_MAX];//Nombre de ports HDMI
- char nbr_minidp[TAILLE_MAX];//Nombre de ports MINIDP
- char usp[TAILLE_MAX];//Unique Selling Points
- char fiab[TAILLE_MAX];//Taux de fiabilité ( % de matériel vendu n'ayant pas montré de défaut)
- char restrict[TAILLE_MAX];//Restrictions d'usage
- char prix[TAILLE_MAX];//Prix
- char perf[TAILLE_MAX];//Indice de performance
- char conso_elec[TAILLE_MAX];//Consommation électrique
- char overclock[TAILLE_MAX];//Coefficient d'overclocking (impacte les performances et la consommation)
- }Graphics;
- typedef struct Hdd{
- char marque[TAILLE_MAX];//Marque
- char modele[TAILLE_MAX];//Modèle
- char capa[TAILLE_MAX];//Espace disque (en Go)
- char port[TAILLE_MAX];//Type de port
- char usp[TAILLE_MAX];//Unique Selling Points
- char fiab[TAILLE_MAX];//Taux de fiabilité ( % de matériel vendu n'ayant pas montré de défaut)
- char restrict[TAILLE_MAX];//Restrictions d'usage
- char prix[TAILLE_MAX];//Prix
- char perf[TAILLE_MAX];//Indice de performance
- char conso_elec[TAILLE_MAX];//Consommation électrique
- }Hdd;
- typedef struct processeur{
- char marque[TAILLE_MAX];
- char modele[TAILLE_MAX];
- char socket[TAILLE_MAX];
- char frequence[TAILLE_MAX];
- char restriction[TAILLE_MAX];
- char uniqueSellingPoint[TAILLE_MAX];
- char nbemplacementRam[TAILLE_MAX];
- char fiab[TAILLE_MAX];
- char prix[TAILLE_MAX];
- char indiceDePerf[TAILLE_MAX];
- char consoElec[TAILLE_MAX];
- char coefOverclock[TAILLE_MAX];
- }processeur;
- typedef struct caracEcran{
- char marque[TAILLE_MAX];
- char modele[TAILLE_MAX];
- char taille[TAILLE_MAX];
- char resolMax[TAILLE_MAX];
- char typePort[TAILLE_MAX];
- char uniqueSellingPoint[TAILLE_MAX];
- char restriction[TAILLE_MAX];
- char prix[TAILLE_MAX];
- char indiceDePerf[TAILLE_MAX];
- char consoElec[TAILLE_MAX];
- }caracEcran;
- typedef struct Ram{
- char marque[TAILLE_MAX];
- char modele[TAILLE_MAX];
- char ver_ram[TAILLE_MAX];
- char freq[TAILLE_MAX];
- char ram_mod[TAILLE_MAX];
- char fiab[TAILLE_MAX];
- char restrict[TAILLE_MAX];
- char prix[TAILLE_MAX];
- char perform[TAILLE_MAX];
- char cons_elec[TAILLE_MAX];
- char overclock[TAILLE_MAX];
- }Ram;
- typedef struct Soft{
- char soft[TAILLE_MAX];//Nom du logiciel
- char ram[TAILLE_MAX];//RAM nécessaire
- char rom[TAILLE_MAX];//Espace disque nécessaire
- char puis_graph[TAILLE_MAX];//Puissance graphique nécessaire (X = aucun pré-requis)
- char puis_proc[TAILLE_MAX];//Puissance processeur nécessaire
- char usp[TAILLE_MAX];//Unique Selling Points nécessaires (X = aucun pré-requis)
- }Soft;
- // Define a function to do more than strtok
- // str_split will return an array of all delimited string
- char** str_split(char* str, char delim)
- {
- char** ret;
- int retLen;
- char* c;
- if ((str == NULL ) || (delim == '\0'))
- {
- /* Either of those will cause problems */
- ret = NULL;
- retLen = -1;
- }
- else
- {
- retLen = 0;
- c = str;
- /* Pre-calculate number of elements */
- do
- {
- if (*c == delim)
- retLen++;
- c++;
- } while (*c != '\0');
- ret = malloc((retLen + 1) * sizeof(*ret));
- ret[retLen] = NULL;
- c = str;
- retLen = 1;
- ret[0] = str;
- do
- {
- if (*c == delim)
- {
- ret[retLen++] = &c[1];
- *c = '\0';
- }
- c++;
- } while ( *c != '\0' );
- }
- return ret;
- }
- void ouverture_ram(Ram ram_array[11]){
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("RAM.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our ram array to store all lines in CSV file
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- Ram ram;
- // copy the content of each properties in the structure
- strcpy(ram.marque, array[0]);
- strcpy(ram.modele, array[1]);
- strcpy(ram.ver_ram, array[2]);
- strcpy(ram.freq, array[3]);
- strcpy(ram.ram_mod, array[4]);
- strcpy(ram.fiab, array[5]);
- strcpy(ram.restrict, array[6]);
- strcpy(ram.prix, array[7]);
- strcpy(ram.perform, array[8]);
- strcpy(ram.cons_elec, array[9]);
- strcpy(ram.overclock, array[10]);
- // add this structure in the array defined previousment
- ram_array[cpt++] = ram;
- }
- fclose(fichier);
- }
- void ouverture_motherboard(Motherboard motherboard_array[18]){
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("MOTHERBOARD.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our motherboard array to store all lines in CSV file
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- Motherboard motherboard;
- // copy the content of each properties in the structure
- strcpy(motherboard.marque, array[0]);
- strcpy(motherboard.modele, array[1]);
- strcpy(motherboard.socket_proc, array[2]);
- strcpy(motherboard.nbr_socket, array[3]);
- strcpy(motherboard.nbr_ram, array[4]);
- strcpy(motherboard.ver_ram, array[5]);
- strcpy(motherboard.nbr_pci, array[6]);
- strcpy(motherboard.nbr_ide, array[7]);
- strcpy(motherboard.nbr_sata, array[8]);
- strcpy(motherboard.nbr_usb, array[9]);
- strcpy(motherboard.nbr_vga, array[10]);
- strcpy(motherboard.nbr_reseau, array[11]);
- strcpy(motherboard.format, array[12]);
- strcpy(motherboard.usp, array[13]);
- strcpy(motherboard.fiab, array[14]);
- strcpy(motherboard.restrict, array[15]);
- strcpy(motherboard.prix, array[16]);
- strcpy(motherboard.conso_elec, array[17]);
- strcpy(motherboard.overclock, array[18]);
- // add this structure in the array defined previousment
- motherboard_array[cpt++] = motherboard;
- }
- fclose(fichier);
- }
- void ouverture_graphics(Graphics graphics_array[12]){
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("GRAPHICS.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our graphics array to store all lines in CSV file
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- Graphics graphics;
- // copy the content of each properties in the structure
- strcpy(graphics.marque, array[0]);
- strcpy(graphics.modele, array[1]);
- strcpy(graphics.nbr_vga, array[2]);
- strcpy(graphics.nbr_dvi, array[3]);
- strcpy(graphics.nbr_hdmi, array[4]);
- strcpy(graphics.nbr_minidp, array[5]);
- strcpy(graphics.usp, array[6]);
- strcpy(graphics.fiab, array[7]);
- strcpy(graphics.restrict, array[8]);
- strcpy(graphics.prix, array[9]);
- strcpy(graphics.perf, array[10]);
- strcpy(graphics.conso_elec, array[11]);
- strcpy(graphics.overclock, array[12]);
- // add this structure in the array defined previousment
- graphics_array[cpt++] = graphics;
- }
- fclose(fichier);
- }
- void ouverture_hdd(Hdd hdd_array[9]){
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("HDD.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our hdd array to store all lines in CSV file
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- Hdd hdd;
- // copy the content of each properties in the structure
- strcpy(hdd.marque, array[0]);
- strcpy(hdd.modele, array[1]);
- strcpy(hdd.capa, array[2]);
- strcpy(hdd.port, array[3]);
- strcpy(hdd.usp, array[4]);
- strcpy(hdd.fiab, array[5]);
- strcpy(hdd.restrict, array[6]);
- strcpy(hdd.prix, array[7]);
- strcpy(hdd.perf, array[8]);
- strcpy(hdd.conso_elec, array[9]);
- // add this structure in the array defined previousment
- hdd_array[cpt++] = hdd;
- }
- fclose(fichier);
- }
- void ouverture_Ecran()
- {
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("ECRAN.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our proco array to store all lines in CSV file
- caracEcran ecran_array[5];
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- caracEcran ecran;
- // copy the content of each properties in the structure
- strcpy(ecran.marque, array[0]);
- strcpy(ecran.modele, array[1]);
- strcpy(ecran.taille, array[2]);
- strcpy(ecran.resolMax, array[3]);
- strcpy(ecran.typePort, array[4]);
- strcpy(ecran.uniqueSellingPoint, array[5]);
- strcpy(ecran.restriction, array[6]);
- strcpy(ecran.prix, array[7]);
- strcpy(ecran.indiceDePerf, array[8]);
- strcpy(ecran.consoElec, array[9]);
- // add this structure in the array defined previousment
- ecran_array[cpt++] = ecran;
- }
- fclose(fichier);
- }
- void ouverture_proco(processeur proco_array[11])
- {
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("PROCO.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our proco array to store all lines in CSV file
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- processeur proco;
- // copy the content of each properties in the structure
- strcpy(proco.marque, array[0]);
- strcpy(proco.modele, array[1]);
- strcpy(proco.socket, array[2]);
- strcpy(proco.frequence, array[3]);
- strcpy(proco.nbemplacementRam, array[4]);
- strcpy(proco.uniqueSellingPoint, array[5]);
- strcpy(proco.fiab, array[6]);
- strcpy(proco.restriction, array[7]);
- strcpy(proco.prix, array[8]);
- strcpy(proco.indiceDePerf, array[9]);
- strcpy(proco.consoElec, array[10]);
- strcpy(proco.coefOverclock, array[11]);
- // add this structure in the array defined previousment
- proco_array[cpt++] = proco;
- }
- // Print to test
- int i;
- for(i = 0; i < 8; i++)
- {
- printf("marque : %s\n", proco_array[i].marque);
- printf("modele : %s\n", proco_array[i].modele);
- printf("socket : %s\n", proco_array[i].socket);
- printf("frequence : %s\n", proco_array[i].frequence);
- printf("Nb Emplacement ram: %s\n",proco_array[i].nbemplacementRam);
- printf("\n");
- }
- fclose(fichier);
- }
- int demande_proco(processeur proco_array[11], processeur* proco_recherche)
- {
- int rep;
- system("cls");
- printf("Souhaitez vous une marque en particulier ? \nAppuyez sur 1 si vous le souhaitez sinon laissez vous guider et tapez n'importe quel case..");
- scanf("%d", &rep);
- if (rep==1)
- {
- int i;
- printf("Quel marque tu veux proco ?");
- scanf("%s", proco_recherche->marque);
- for(i=0; i<8; i++)
- {
- if (strcmp(proco_recherche->marque, proco_array[i].marque)==0)
- {
- printf("Ca marche\n");
- printf("Quel modele souhaites-tu ?");
- scanf("%s", proco_recherche->modele);
- for(i=0; i<8; i++)
- {
- if(strcmp(proco_recherche, proco_array[i].modele));
- }
- }
- }
- printf("Ta marque n'est pas dans notre base de donnees.. \n");
- }
- else
- {
- return 0;
- }
- }
- void affichage_ram()
- {
- printf("1: Marque\n");
- printf("2: Modele\n");
- printf("3: Version de la RAM\n");
- printf("4: Frequence\n");
- printf("5: Quantité par module\n");
- printf("6: Taux de fiabilité du matériel\n");
- printf("7: Prix\n");
- printf("8: Indice de performance\n");
- printf("9: Consommation electrique\n");
- printf("10: Coefficient d'overclocking\n");
- }
- void demande_ram(Ram ram_array[11], Ram* ram_recherche)
- {
- int rep;
- int i;
- do
- {
- system("cls");
- printf("Quel parametres souhaitez vous parametrer?\n");
- affichage_ram();
- scanf("%d", &rep);
- if(rep==1)
- {
- printf("Saisir la marque souhaitee");
- scanf("%s", ram_recherche->marque);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->marque, ram_array[i].marque)==0)
- {
- printf("Nous avons trouvé la marque\n");
- }
- }
- }
- if(rep==2)
- {
- printf("Saisir le modele souhaite");
- scanf("%s", ram_recherche->modele);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->modele, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé le modele\n");
- }
- }
- }
- if(rep==3)
- {
- printf("Saisir la version de la ram");
- scanf("%s", ram_recherche->ver_ram);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->ver_ram, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé la version de la ram\n");
- }
- }
- }
- if(rep==4)
- {
- printf("Saisir la frequence");
- scanf("%s", ram_recherche->freq);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->freq, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé la frequence\n");
- }
- }
- }
- if(rep==5)
- {
- printf("Saisir la quantité par module");
- scanf("%s", ram_recherche->ram_mod);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->ram_mod, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé la quantité\n");
- }
- }
- }
- if(rep==6)
- {
- printf("Saisir le taux de fiabilité");
- scanf("%s", ram_recherche->fiab);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->fiab, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé le taux de fiab\n");
- }
- }
- }
- if(rep==7)
- {
- printf("Saisir le prix");
- scanf("%s", ram_recherche->prix);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->prix, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé le prix\n");
- }
- }
- }
- if(rep==8)
- {
- printf("Saisir l'indice de performance");
- scanf("%s", ram_recherche->perform);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->perform, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé l'indice de performance\n");
- }
- }
- }
- if(rep==9)
- {
- printf("Saisir la consommation electrique");
- scanf("%s", ram_recherche->cons_elec);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->cons_elec, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé l'indice de performance\n");
- }
- }
- }
- if(rep==10)
- {
- printf("Saisir le coefficient d'overclocking");
- scanf("%s", ram_recherche->overclock);
- for(i=0; i<18; i++)
- {
- if (strcmp(ram_recherche->overclock, ram_array[i].modele)==0)
- {
- printf("Nous avons trouvé l'indice de performance\n");
- }
- }
- }
- }while(rep!=0);
- }
- int main()
- {
- int i;
- processeur proco_array[11];
- Ram ram_array[11];
- processeur proco_recherche;
- Ram ram_recherche;
- Ram sortie;
- ouverture_proco(proco_array);
- ouverture_ram(ram_array);
- ouverture_Ecran();
- //demande_proco(proco_array, &proco_recherche);
- demande_ram(ram_array, &ram_recherche);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement