Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct El{
  5.     int info;
  6.     struct El *next;
  7. };
  8. typedef struct El ElementoLista;
  9.  
  10. void add_head(ElementoLista **list, int n){
  11.     ElementoLista *new= malloc(sizeof(ElementoLista));
  12.     new->info=n;
  13.     new->next=*list;
  14.     *list=new;
  15. }
  16.  
  17. void cancRec(ElementoLista **list, int v){
  18.     ElementoLista *prec= NULL;
  19.     ElementoLista *corr= *list;
  20.     if(corr != NULL){
  21.         if(corr->info%v==0){
  22.             if(prec==NULL){
  23.                 *list=*list->next;
  24.             } else {
  25.                 prec=
  26.         }
  27.         cancRec(&list, v);
  28.     }
  29.            
  30. }
  31.  
  32. /*int RecLenght(ElementoLista *list){
  33.     int c;
  34.     if(list == NULL){
  35.         c=0;
  36.     } else {
  37.         c=1+RecLenght(list->next);
  38.     }
  39.     return c;
  40. }*/
  41.  
  42.  
  43.  
  44. /void RecStampa(ElementoLista *list){
  45.     if(list == NULL){
  46.         printf("NULL");
  47.     } else {
  48.         printf("%d -> ", list->info);
  49.         RecStampa(list->next);
  50.     }
  51. }
  52.        
  53.  
  54. int main(void) {
  55.     ElementoLista *list= NULL;
  56.     int n, v;
  57.     scanf("%d", &n);
  58.     scanf("%d", &n);
  59.     while(n>=0){
  60.         add_head(&list, n);
  61.         scanf("%d", &n);
  62.     }
  63.     cancRec(&list, v);
  64.     //printf("%d", RecLenght(list));
  65.     RecStampa(list);
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement