Advertisement
RayanRam

Past exposure

May 17th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. typedef struct pile
  6. {
  7. int val;
  8. struct pile *suiv;
  9. }pile;
  10. int main(int argc, char *argv[])
  11. {
  12. pile* P;
  13. pile* L;
  14. pile* Q;
  15. int x;
  16. int bar;
  17. bar=0;
  18. char s[25];
  19. printf("Commencer ? ");
  20. scanf("%s",s);
  21. do
  22. {
  23. printf("Donnez la valeur ? \n");
  24. scanf("%d",&x);
  25. if(bar==0)
  26. {
  27. L = (*pile)malloc(sizeof(pile));
  28. L->val=x;
  29. L->suiv=NULL;
  30. }
  31. else
  32. { P=L;
  33. Q=P->suiv;
  34.  
  35. while(P->suiv!=NULL && Q->val>x)
  36. {
  37. P=P->suiv;
  38. Q=P->suiv;
  39. }
  40. Q=(*pile)malloc(sizeof(pile));
  41. Q->suiv=P->suiv;
  42. P->suiv=Q;
  43. Q->val=x;
  44. }
  45.  
  46. printf("Continuer ? \n");
  47. scanf("%s",s);
  48.  
  49.  
  50.  
  51.  
  52. scanf("%s",s);
  53. }while(strcmp(s,"NON")!=0);
  54. P=L;
  55. while(P->suiv!=NULL)
  56. {printf("%d",P->val);
  57. P=P->suiv;
  58. }
  59. system("PAUSE");
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement