Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #define DIM 100
- void crearray(int*,int);
- void visualizza(int*,int);
- struct lista
- {
- int num;
- int ugdiv;
- struct lista *next;
- };
- struct lista *crealista(struct lista*,int,int*,int*);
- void visualizzalista(struct lista *);
- int main()
- {
- int N,v[DIM],v1[DIM];
- struct lista *s=NULL;
- printf("inserire dimensione array: ");
- scanf("%d",&N);
- printf ("\ninserimento primo array; \n");
- crearray(v,N);
- printf("primo array: \n");
- visualizza(v,N);
- printf ("\ninserimento secondo array; \n");
- crearray(v1,N);
- printf("secondo array: \n");
- visualizza(v1,N);
- crealista(s,N,v,v1);
- visualizzalista(s);
- }
- void crearray(int*a,int b)
- {
- int i;
- for (i=0;i<b;i++)
- {
- printf("inserire %d' valore ",i+1);
- scanf("%d",a+i);
- }
- }
- void visualizza(int*a,int b)
- {
- int i;
- for (i=0;i<b;i++)
- printf("%d ",*(a+i));
- }
- struct lista *crealista(struct lista *p, int a, int *b, int *c)
- {
- int i=0;
- struct lista *paux;
- p=(struct lista*)malloc(sizeof(struct lista));
- paux=p;
- while (i<a)
- {
- paux->next=(struct lista*)malloc(sizeof(struct lista));
- paux=paux->next;
- paux->next=NULL;
- if(b[i]==c[i])
- {
- paux->num=i+1;
- paux->ugdiv=1;
- }
- else
- {
- paux->num=i+1;
- paux->ugdiv=0;
- }
- i++;
- }
- return p;
- }
- void visualizzalista(struct lista *p)
- {
- while (p!=NULL)
- {
- printf (" (%d,%d)-> ", p->num, p->ugdiv);
- p=p->next;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement