Advertisement
Guest User

Untitled

a guest
May 25th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define TAILLE_MAX 150
  5.  
  6. typedef struct Motherboard{
  7. char marque[TAILLE_MAX];
  8. char modele[TAILLE_MAX];
  9. char socket_proc[TAILLE_MAX];
  10. char nbr_socket[TAILLE_MAX];
  11. char nbr_ram[TAILLE_MAX];
  12. char ver_ram[TAILLE_MAX];
  13. char nbr_pci[TAILLE_MAX];
  14. char nbr_ide[TAILLE_MAX];
  15. char nbr_sata[TAILLE_MAX];
  16. char nbr_usb[TAILLE_MAX];
  17. char nbr_vga[TAILLE_MAX];
  18. char nbr_reseau[TAILLE_MAX];
  19. char format[TAILLE_MAX];
  20. char usp[TAILLE_MAX];
  21. char fiab[TAILLE_MAX];
  22. char restrict[TAILLE_MAX];
  23. char prix[TAILLE_MAX];
  24. char conso_elec[TAILLE_MAX];
  25. char overclock[TAILLE_MAX];
  26. }Motherboard;
  27.  
  28. typedef struct Graphics{
  29.  
  30. char marque[TAILLE_MAX];//Marque
  31. char modele[TAILLE_MAX];//Modèle
  32. char nbr_vga[TAILLE_MAX];//Nombre de ports VGA
  33. char nbr_dvi[TAILLE_MAX];//Nombre de ports DVI
  34. char nbr_hdmi[TAILLE_MAX];//Nombre de ports HDMI
  35. char nbr_minidp[TAILLE_MAX];//Nombre de ports MINIDP
  36. char usp[TAILLE_MAX];//Unique Selling Points
  37. char fiab[TAILLE_MAX];//Taux de fiabilité ( % de matériel vendu n'ayant pas montré de défaut)
  38. char restrict[TAILLE_MAX];//Restrictions d'usage
  39. char prix[TAILLE_MAX];//Prix
  40. char perf[TAILLE_MAX];//Indice de performance
  41. char conso_elec[TAILLE_MAX];//Consommation électrique
  42. char overclock[TAILLE_MAX];//Coefficient d'overclocking (impacte les performances et la consommation)
  43. }Graphics;
  44.  
  45. typedef struct Hdd{
  46. char marque[TAILLE_MAX];//Marque
  47. char modele[TAILLE_MAX];//Modèle
  48. char capa[TAILLE_MAX];//Espace disque (en Go)
  49. char port[TAILLE_MAX];//Type de port
  50. char usp[TAILLE_MAX];//Unique Selling Points
  51. char fiab[TAILLE_MAX];//Taux de fiabilité ( % de matériel vendu n'ayant pas montré de défaut)
  52. char restrict[TAILLE_MAX];//Restrictions d'usage
  53. char prix[TAILLE_MAX];//Prix
  54. char perf[TAILLE_MAX];//Indice de performance
  55. char conso_elec[TAILLE_MAX];//Consommation électrique
  56. }Hdd;
  57.  
  58. typedef struct processeur{
  59.  
  60. char marque[TAILLE_MAX];
  61. char modele[TAILLE_MAX];
  62. char socket[TAILLE_MAX];
  63. char frequence[TAILLE_MAX];
  64. char restriction[TAILLE_MAX];
  65. char uniqueSellingPoint[TAILLE_MAX];
  66. char nbemplacementRam[TAILLE_MAX];
  67. char fiab[TAILLE_MAX];
  68. char prix[TAILLE_MAX];
  69. char indiceDePerf[TAILLE_MAX];
  70. char consoElec[TAILLE_MAX];
  71. char coefOverclock[TAILLE_MAX];
  72. }processeur;
  73.  
  74. typedef struct caracEcran{
  75.  
  76. char marque[TAILLE_MAX];
  77. char modele[TAILLE_MAX];
  78. char taille[TAILLE_MAX];
  79. char resolMax[TAILLE_MAX];
  80. char typePort[TAILLE_MAX];
  81. char uniqueSellingPoint[TAILLE_MAX];
  82. char restriction[TAILLE_MAX];
  83. char prix[TAILLE_MAX];
  84. char indiceDePerf[TAILLE_MAX];
  85. char consoElec[TAILLE_MAX];
  86. }caracEcran;
  87.  
  88. typedef struct Ram{
  89.  
  90. char marque[TAILLE_MAX];
  91. char modele[TAILLE_MAX];
  92. char ver_ram[TAILLE_MAX];
  93. char freq[TAILLE_MAX];
  94. char ram_mod[TAILLE_MAX];
  95. char fiab[TAILLE_MAX];
  96. char restrict[TAILLE_MAX];
  97. char prix[TAILLE_MAX];
  98. char perform[TAILLE_MAX];
  99. char cons_elec[TAILLE_MAX];
  100. char overclock[TAILLE_MAX];
  101. }Ram;
  102.  
  103. typedef struct Soft{
  104. char soft[TAILLE_MAX];//Nom du logiciel
  105. char ram[TAILLE_MAX];//RAM nécessaire
  106. char rom[TAILLE_MAX];//Espace disque nécessaire
  107. char puis_graph[TAILLE_MAX];//Puissance graphique nécessaire (X = aucun pré-requis)
  108. char puis_proc[TAILLE_MAX];//Puissance processeur nécessaire
  109. char usp[TAILLE_MAX];//Unique Selling Points nécessaires (X = aucun pré-requis)
  110. }Soft;
  111.  
  112.  
  113. // Define a function to do more than strtok
  114. // str_split will return an array of all delimited string
  115.  
  116. char** str_split(char* str, char delim)
  117. {
  118. char** ret;
  119. int retLen;
  120. char* c;
  121.  
  122. if ((str == NULL ) || (delim == '\0'))
  123. {
  124. /* Either of those will cause problems */
  125. ret = NULL;
  126. retLen = -1;
  127. }
  128. else
  129. {
  130. retLen = 0;
  131. c = str;
  132.  
  133. /* Pre-calculate number of elements */
  134. do
  135. {
  136. if (*c == delim)
  137. retLen++;
  138.  
  139. c++;
  140. } while (*c != '\0');
  141.  
  142. ret = malloc((retLen + 1) * sizeof(*ret));
  143. ret[retLen] = NULL;
  144.  
  145. c = str;
  146. retLen = 1;
  147. ret[0] = str;
  148.  
  149. do
  150. {
  151. if (*c == delim)
  152. {
  153. ret[retLen++] = &c[1];
  154. *c = '\0';
  155. }
  156.  
  157. c++;
  158. } while ( *c != '\0' );
  159. }
  160. return ret;
  161. }
  162.  
  163. void ouverture_ram(Ram ram_array[11]){
  164. FILE* fichier = NULL;
  165. char caractere[TAILLE_MAX];
  166.  
  167. fichier = fopen("RAM.csv", "r");
  168. if(fichier != NULL)
  169. {
  170. }
  171. else
  172. {
  173. printf("impossible d'ouvrir le fichier");
  174. }
  175.  
  176. // Define our ram array to store all lines in CSV file
  177.  
  178. int cpt = 0;
  179. // get the whole line for each
  180. while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  181. {
  182. // Get all the strings delimited by a ';'
  183. char ** array = str_split(caractere, ';');
  184.  
  185. // Define a new structure
  186. Ram ram;
  187.  
  188. // copy the content of each properties in the structure
  189. strcpy(ram.marque, array[0]);
  190. strcpy(ram.modele, array[1]);
  191. strcpy(ram.ver_ram, array[2]);
  192. strcpy(ram.freq, array[3]);
  193. strcpy(ram.ram_mod, array[4]);
  194. strcpy(ram.fiab, array[5]);
  195. strcpy(ram.restrict, array[6]);
  196. strcpy(ram.prix, array[7]);
  197. strcpy(ram.perform, array[8]);
  198. strcpy(ram.cons_elec, array[9]);
  199. strcpy(ram.overclock, array[10]);
  200.  
  201. // add this structure in the array defined previousment
  202. ram_array[cpt++] = ram;
  203. }
  204.  
  205. fclose(fichier);
  206. }
  207.  
  208. void ouverture_motherboard(Motherboard motherboard_array[18]){
  209. FILE* fichier = NULL;
  210. char caractere[TAILLE_MAX];
  211.  
  212. fichier = fopen("MOTHERBOARD.csv", "r");
  213. if(fichier != NULL)
  214. {
  215. }
  216. else
  217. {
  218. printf("impossible d'ouvrir le fichier");
  219. }
  220.  
  221. // Define our motherboard array to store all lines in CSV file
  222.  
  223. int cpt = 0;
  224. // get the whole line for each
  225. while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  226. {
  227. // Get all the strings delimited by a ';'
  228. char ** array = str_split(caractere, ';');
  229.  
  230. // Define a new structure
  231. Motherboard motherboard;
  232.  
  233. // copy the content of each properties in the structure
  234. strcpy(motherboard.marque, array[0]);
  235. strcpy(motherboard.modele, array[1]);
  236. strcpy(motherboard.socket_proc, array[2]);
  237. strcpy(motherboard.nbr_socket, array[3]);
  238. strcpy(motherboard.nbr_ram, array[4]);
  239. strcpy(motherboard.ver_ram, array[5]);
  240. strcpy(motherboard.nbr_pci, array[6]);
  241. strcpy(motherboard.nbr_ide, array[7]);
  242. strcpy(motherboard.nbr_sata, array[8]);
  243. strcpy(motherboard.nbr_usb, array[9]);
  244. strcpy(motherboard.nbr_vga, array[10]);
  245. strcpy(motherboard.nbr_reseau, array[11]);
  246. strcpy(motherboard.format, array[12]);
  247. strcpy(motherboard.usp, array[13]);
  248. strcpy(motherboard.fiab, array[14]);
  249. strcpy(motherboard.restrict, array[15]);
  250. strcpy(motherboard.prix, array[16]);
  251. strcpy(motherboard.conso_elec, array[17]);
  252. strcpy(motherboard.overclock, array[18]);
  253.  
  254. // add this structure in the array defined previousment
  255. motherboard_array[cpt++] = motherboard;
  256. }
  257.  
  258. fclose(fichier);
  259. }
  260.  
  261. void ouverture_graphics(Graphics graphics_array[12]){
  262. FILE* fichier = NULL;
  263. char caractere[TAILLE_MAX];
  264.  
  265. fichier = fopen("GRAPHICS.csv", "r");
  266. if(fichier != NULL)
  267. {
  268. }
  269. else
  270. {
  271. printf("impossible d'ouvrir le fichier");
  272. }
  273.  
  274. // Define our graphics array to store all lines in CSV file
  275.  
  276. int cpt = 0;
  277. // get the whole line for each
  278. while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  279. {
  280. // Get all the strings delimited by a ';'
  281. char ** array = str_split(caractere, ';');
  282.  
  283. // Define a new structure
  284. Graphics graphics;
  285.  
  286. // copy the content of each properties in the structure
  287. strcpy(graphics.marque, array[0]);
  288. strcpy(graphics.modele, array[1]);
  289. strcpy(graphics.nbr_vga, array[2]);
  290. strcpy(graphics.nbr_dvi, array[3]);
  291. strcpy(graphics.nbr_hdmi, array[4]);
  292. strcpy(graphics.nbr_minidp, array[5]);
  293. strcpy(graphics.usp, array[6]);
  294. strcpy(graphics.fiab, array[7]);
  295. strcpy(graphics.restrict, array[8]);
  296. strcpy(graphics.prix, array[9]);
  297. strcpy(graphics.perf, array[10]);
  298. strcpy(graphics.conso_elec, array[11]);
  299. strcpy(graphics.overclock, array[12]);
  300.  
  301. // add this structure in the array defined previousment
  302. graphics_array[cpt++] = graphics;
  303. }
  304.  
  305. fclose(fichier);
  306. }
  307.  
  308. void ouverture_hdd(Hdd hdd_array[9]){
  309. FILE* fichier = NULL;
  310. char caractere[TAILLE_MAX];
  311.  
  312. fichier = fopen("HDD.csv", "r");
  313. if(fichier != NULL)
  314. {
  315. }
  316. else
  317. {
  318. printf("impossible d'ouvrir le fichier");
  319. }
  320.  
  321. // Define our hdd array to store all lines in CSV file
  322.  
  323. int cpt = 0;
  324. // get the whole line for each
  325. while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  326. {
  327. // Get all the strings delimited by a ';'
  328. char ** array = str_split(caractere, ';');
  329.  
  330. // Define a new structure
  331. Hdd hdd;
  332.  
  333. // copy the content of each properties in the structure
  334. strcpy(hdd.marque, array[0]);
  335. strcpy(hdd.modele, array[1]);
  336. strcpy(hdd.capa, array[2]);
  337. strcpy(hdd.port, array[3]);
  338. strcpy(hdd.usp, array[4]);
  339. strcpy(hdd.fiab, array[5]);
  340. strcpy(hdd.restrict, array[6]);
  341. strcpy(hdd.prix, array[7]);
  342. strcpy(hdd.perf, array[8]);
  343. strcpy(hdd.conso_elec, array[9]);
  344.  
  345. // add this structure in the array defined previousment
  346. hdd_array[cpt++] = hdd;
  347. }
  348.  
  349. fclose(fichier);
  350. }
  351.  
  352. void ouverture_Ecran()
  353. {
  354. FILE* fichier = NULL;
  355. char caractere[TAILLE_MAX];
  356.  
  357. fichier = fopen("ECRAN.csv", "r");
  358. if(fichier != NULL)
  359. {
  360. }
  361. else
  362. {
  363. printf("impossible d'ouvrir le fichier");
  364. }
  365.  
  366. // Define our proco array to store all lines in CSV file
  367. caracEcran ecran_array[5];
  368.  
  369. int cpt = 0;
  370. // get the whole line for each
  371. while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  372. {
  373. // Get all the strings delimited by a ';'
  374. char ** array = str_split(caractere, ';');
  375.  
  376. // Define a new structure
  377. caracEcran ecran;
  378.  
  379. // copy the content of each properties in the structure
  380. strcpy(ecran.marque, array[0]);
  381. strcpy(ecran.modele, array[1]);
  382. strcpy(ecran.taille, array[2]);
  383. strcpy(ecran.resolMax, array[3]);
  384. strcpy(ecran.typePort, array[4]);
  385. strcpy(ecran.uniqueSellingPoint, array[5]);
  386. strcpy(ecran.restriction, array[6]);
  387. strcpy(ecran.prix, array[7]);
  388. strcpy(ecran.indiceDePerf, array[8]);
  389. strcpy(ecran.consoElec, array[9]);
  390.  
  391.  
  392. // add this structure in the array defined previousment
  393. ecran_array[cpt++] = ecran;
  394. }
  395.  
  396. fclose(fichier);
  397. }
  398.  
  399. void ouverture_proco(processeur proco_array[11])
  400. {
  401. FILE* fichier = NULL;
  402. char caractere[TAILLE_MAX];
  403.  
  404. fichier = fopen("PROCO.csv", "r");
  405. if(fichier != NULL)
  406. {
  407. }
  408. else
  409. {
  410. printf("impossible d'ouvrir le fichier");
  411. }
  412.  
  413. // Define our proco array to store all lines in CSV file
  414.  
  415.  
  416. int cpt = 0;
  417. // get the whole line for each
  418. while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  419. {
  420. // Get all the strings delimited by a ';'
  421. char ** array = str_split(caractere, ';');
  422.  
  423. // Define a new structure
  424. processeur proco;
  425.  
  426. // copy the content of each properties in the structure
  427. strcpy(proco.marque, array[0]);
  428. strcpy(proco.modele, array[1]);
  429. strcpy(proco.socket, array[2]);
  430. strcpy(proco.frequence, array[3]);
  431. strcpy(proco.nbemplacementRam, array[4]);
  432. strcpy(proco.uniqueSellingPoint, array[5]);
  433. strcpy(proco.fiab, array[6]);
  434. strcpy(proco.restriction, array[7]);
  435. strcpy(proco.prix, array[8]);
  436. strcpy(proco.indiceDePerf, array[9]);
  437. strcpy(proco.consoElec, array[10]);
  438. strcpy(proco.coefOverclock, array[11]);
  439.  
  440. // add this structure in the array defined previousment
  441. proco_array[cpt++] = proco;
  442. }
  443.  
  444. // Print to test
  445. int i;
  446. for(i = 0; i < 8; i++)
  447. {
  448. printf("marque : %s\n", proco_array[i].marque);
  449. printf("modele : %s\n", proco_array[i].modele);
  450. printf("socket : %s\n", proco_array[i].socket);
  451. printf("frequence : %s\n", proco_array[i].frequence);
  452. printf("Nb Emplacement ram: %s\n",proco_array[i].nbemplacementRam);
  453.  
  454.  
  455. printf("\n");
  456. }
  457.  
  458. fclose(fichier);
  459. }
  460.  
  461. int demande_proco(processeur proco_array[11], processeur* proco_recherche)
  462. {
  463. int rep;
  464. system("cls");
  465. printf("Souhaitez vous une marque en particulier ? \nAppuyez sur 1 si vous le souhaitez sinon laissez vous guider et tapez n'importe quel case..");
  466. scanf("%d", &rep);
  467. if (rep==1)
  468. {
  469.  
  470. int i;
  471. printf("Quel marque tu veux proco ?");
  472. scanf("%s", proco_recherche->marque);
  473. for(i=0; i<8; i++)
  474. {
  475. if (strcmp(proco_recherche->marque, proco_array[i].marque)==0)
  476. {
  477. printf("Ca marche\n");
  478. printf("Quel modele souhaites-tu ?");
  479. scanf("%s", proco_recherche->modele);
  480. for(i=0; i<8; i++)
  481. {
  482. if(strcmp(proco_recherche, proco_array[i].modele));
  483. }
  484. }
  485.  
  486. }
  487. printf("Ta marque n'est pas dans notre base de donnees.. \n");
  488. }
  489. else
  490. {
  491. return 0;
  492. }
  493.  
  494. }
  495.  
  496. void affichage_ram()
  497. {
  498. printf("1: Marque\n");
  499. printf("2: Modele\n");
  500. printf("3: Version de la RAM\n");
  501. printf("4: Frequence\n");
  502. printf("5: Quantité par module\n");
  503. printf("6: Taux de fiabilité du matériel\n");
  504. printf("7: Prix\n");
  505. printf("8: Indice de performance\n");
  506. printf("9: Consommation electrique\n");
  507. printf("10: Coefficient d'overclocking\n");
  508. }
  509.  
  510. void demande_ram(Ram ram_array[11], Ram* ram_recherche)
  511. {
  512. int rep;
  513. int i;
  514. do
  515. {
  516.  
  517. system("cls");
  518. printf("Quel parametres souhaitez vous parametrer?\n");
  519. affichage_ram();
  520.  
  521. scanf("%d", &rep);
  522.  
  523. if(rep==1)
  524. {
  525. printf("Saisir la marque souhaitee");
  526. scanf("%s", ram_recherche->marque);
  527. for(i=0; i<18; i++)
  528. {
  529. if (strcmp(ram_recherche->marque, ram_array[i].marque)==0)
  530. {
  531. printf("Nous avons trouvé la marque\n");
  532. }
  533.  
  534. }
  535. }
  536.  
  537. if(rep==2)
  538. {
  539. printf("Saisir le modele souhaite");
  540. scanf("%s", ram_recherche->modele);
  541. for(i=0; i<18; i++)
  542. {
  543. if (strcmp(ram_recherche->modele, ram_array[i].modele)==0)
  544. {
  545. printf("Nous avons trouvé le modele\n");
  546. }
  547.  
  548. }
  549. }
  550. if(rep==3)
  551. {
  552. printf("Saisir la version de la ram");
  553. scanf("%s", ram_recherche->ver_ram);
  554. for(i=0; i<18; i++)
  555. {
  556. if (strcmp(ram_recherche->ver_ram, ram_array[i].modele)==0)
  557. {
  558. printf("Nous avons trouvé la version de la ram\n");
  559. }
  560.  
  561. }
  562.  
  563. }
  564. if(rep==4)
  565. {
  566. printf("Saisir la frequence");
  567. scanf("%s", ram_recherche->freq);
  568. for(i=0; i<18; i++)
  569. {
  570. if (strcmp(ram_recherche->freq, ram_array[i].modele)==0)
  571. {
  572. printf("Nous avons trouvé la frequence\n");
  573. }
  574.  
  575. }
  576. }
  577. if(rep==5)
  578. {
  579. printf("Saisir la quantité par module");
  580. scanf("%s", ram_recherche->ram_mod);
  581. for(i=0; i<18; i++)
  582. {
  583. if (strcmp(ram_recherche->ram_mod, ram_array[i].modele)==0)
  584. {
  585. printf("Nous avons trouvé la quantité\n");
  586. }
  587.  
  588. }
  589. }
  590. if(rep==6)
  591. {
  592. printf("Saisir le taux de fiabilité");
  593. scanf("%s", ram_recherche->fiab);
  594. for(i=0; i<18; i++)
  595. {
  596. if (strcmp(ram_recherche->fiab, ram_array[i].modele)==0)
  597. {
  598. printf("Nous avons trouvé le taux de fiab\n");
  599. }
  600.  
  601. }
  602. }
  603. if(rep==7)
  604. {
  605. printf("Saisir le prix");
  606. scanf("%s", ram_recherche->prix);
  607. for(i=0; i<18; i++)
  608. {
  609. if (strcmp(ram_recherche->prix, ram_array[i].modele)==0)
  610. {
  611. printf("Nous avons trouvé le prix\n");
  612. }
  613.  
  614. }
  615. }
  616. if(rep==8)
  617. {
  618. printf("Saisir l'indice de performance");
  619. scanf("%s", ram_recherche->perform);
  620. for(i=0; i<18; i++)
  621. {
  622. if (strcmp(ram_recherche->perform, ram_array[i].modele)==0)
  623. {
  624. printf("Nous avons trouvé l'indice de performance\n");
  625. }
  626.  
  627. }
  628. }
  629. if(rep==9)
  630. {
  631. printf("Saisir la consommation electrique");
  632. scanf("%s", ram_recherche->cons_elec);
  633. for(i=0; i<18; i++)
  634. {
  635. if (strcmp(ram_recherche->cons_elec, ram_array[i].modele)==0)
  636. {
  637. printf("Nous avons trouvé l'indice de performance\n");
  638. }
  639.  
  640. }
  641. }
  642. if(rep==10)
  643. {
  644. printf("Saisir le coefficient d'overclocking");
  645. scanf("%s", ram_recherche->overclock);
  646. for(i=0; i<18; i++)
  647. {
  648. if (strcmp(ram_recherche->overclock, ram_array[i].modele)==0)
  649. {
  650. printf("Nous avons trouvé l'indice de performance\n");
  651. }
  652.  
  653. }
  654. }
  655. }while(rep!=0);
  656.  
  657.  
  658. }
  659.  
  660.  
  661. int main()
  662. {
  663. int i;
  664. processeur proco_array[11];
  665. Ram ram_array[11];
  666. processeur proco_recherche;
  667. Ram ram_recherche;
  668. Ram sortie;
  669. ouverture_proco(proco_array);
  670. ouverture_ram(ram_array);
  671. ouverture_Ecran();
  672. //demande_proco(proco_array, &proco_recherche);
  673. demande_ram(ram_array, &ram_recherche);
  674.  
  675.  
  676.  
  677.  
  678. return 0;
  679. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement