Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct pile
- {
- int val;
- struct pile *suiv;
- }pile;
- int main(int argc, char *argv[])
- {
- pile* P;
- pile* L;
- pile* Q;
- int x;
- int bar;
- bar=0;
- char s[25];
- printf("Commencer ? ");
- scanf("%s",s);
- do
- {
- printf("Donnez la valeur ? \n");
- scanf("%d",&x);
- if(bar==0)
- {
- L = (*pile)malloc(sizeof(pile));
- L->val=x;
- L->suiv=NULL;
- }
- else
- { P=L;
- Q=P->suiv;
- while(P->suiv!=NULL && Q->val>x)
- {
- P=P->suiv;
- Q=P->suiv;
- }
- Q=(*pile)malloc(sizeof(pile));
- Q->suiv=P->suiv;
- P->suiv=Q;
- Q->val=x;
- }
- printf("Continuer ? \n");
- scanf("%s",s);
- scanf("%s",s);
- }while(strcmp(s,"NON")==0);
- P=L;
- while(P->suiv!=NULL)
- {printf("%d",P->val);
- P=P->suiv;
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement