Fortune Telling Collection - Comprehensive fortune-telling - To calculate the intersection, union and complement of two integer sets A and B, the intersection, union and complement in A need to be written as a separate function.
To calculate the intersection, union and complement of two integer sets A and B, the intersection, union and complement in A need to be written as a separate function.
# Definition MX 1000
Use namespace std
int main()
{
int n,m,a[2 * MX + 10],b[MX + 10],c[MX + 10],I,j,p = 0,d[MX + 10],f = 0;
CIN & gt; & gtn;
for(I = 1; I < = n; i++)
{
CIN & gt; & gta[I];
}
CIN & gt; & gtm;
for(I = 1; I<= m;; i++)
{
CIN & gt; & gtb[I];
}
Sorting (b+1, b+m+1);
sort(a + 1,a+n+ 1);
for(I = 1; I < = n; i++)
{
c[I]= a[I];
}
for(I = 1; I<= m;; i++)
{
d[I]= b[I];
}
for(I = 1; I < = n; i++)
{
for(j = 1; j & lt= m; J++)// Find the intersection
{
if (a[i] == b[j])
{
cout & lt& lta[I]& lt; & lt" ";
f = 1;
}
}
}
If (f == 1)
{
cout & lt& ltendl
}
for(I = 1; I<= m;; i++)
{
a[n+I]= b[I];
}
Sorting (a+1, a+n+m+1);
for(I = 1; I< = n+m; I++)// Find union
{
cout & lt& lta[I]& lt; & lt" ";
while(a[i] == a[i + 1])
{
i++;
}
}
cout & lt& ltendl
int cnt
for(I = 1; I < = n; I++)// congruent set
{
CNT = 0;
for(j = 1; j & lt= m; j++)
{
if (c[i]! = d[j])
{
cnt++;
}
}
If (cnt == m)
{
cout & lt& ltc[I]& lt; & lt" ";
}
}
Returns 0;
}
The function is to divide them into three parts and put them outside.
- Related articles
- What does the fortune teller mean this year is free?
- * * * column idioms
- I dreamed that a charlatan told my fortune. _ I dreamed that a charlatan counted his own life.
- The orthodox textbook of fortune telling
- Korean star fortune teller
- What disease is screaming in the middle of the night?
- Fortune teller, forget it if you are not allowed, thank you, female, lunar calendar,1994,2, 12 are all dogs,
- How many children do you have by palmprint and palm reading?
1, the arrow-shaped handprint at the beginning of the emotional line has developed reproductive function, and it is easier to get pre
- Tancheng fortune-telling is very accurate _ Tancheng fortune-telling is more accurate.
- Why is Zhao Liying a better actress than being called "Zhao Xiaodao" in variety shows?