Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Ввести значения двух массивов a и b
- и вывести числа массива a,
- которых нет в массиве b.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- typedef unsigned int word;
- void main()
- {
- word set1=0,set2=0;
- const int n=10;
- int a[n],b[n];
- srand(time(0));
- printf("a b\n");
- for(int i=0;i<n;++i)
- {
- a[i]=rand()%32;
- b[i]=rand()%32;
- printf("%d %d \n",a[i],b[i]);
- }
- putchar('\n');
- for(int i=0;i<n;++i)
- {
- set1=set1|(1<<a[i]);
- set2=set2|(1<<b[i]);
- }
- set1=set1^(set1&set2); //удаление чисел, которые состоят в пересечении
- for(int i=0;i<32;++i)
- {
- if(set1&1<<i)
- printf("%d ",i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement