Home > Back-end >  C language array problem: get the intersection of two integers and sorting
C language array problem: get the intersection of two integers and sorting

Time:11-28

 # include 
Int main () {
Int a [100], [100] b, c [100];
Int I, j, t, n, o;
The scanf (" % d ", & amp; N);
for(i=0; i{the scanf (" % d ", & amp; A, ).
}
The scanf (" % d ", & amp; T);
for(i=0; i{the scanf (" % d ", & amp; B [I]);
}
for(i=0; ifor(j=0; jIf (a==b [j] [I]) {c=[I] a [I]; break; }
The else continue;
}
for(i=0; ifor(j=0; j{if (c [j] {t=c [j];
C=c [j] [j + 1);
C [m + 1]=t;
}
}
}
If (c [0]==0) {printf (" No Answer ");
}
Else for (I=0; i{printf (" % d ", [I] c);
}

return 0;
}


Compare two integers have the same set of elements, each group of integer number less than 100, if you have the same element, is the same in the order from large to small output elements (output only a recurring element), if you don't have the same elements, print the string: No Answer,
[form] input

First of all, from the standard input (keyboard) input the number of the first set of integers, then the first set of integer input, with a space division; And then enter the second set of integer number, enter a second set of integers, with a space partition,

[] output form

In the order from large to small to the standard output (display) output two of the same element in the set of integers, in a space separated; If you don't have the same elements, the print No Answer

[input sample]

9
2 5 10 17 October 8 10 12
7
17 May 12 August 10, 1009 2

[output sample]

17 December 10 8 5 2

 



ps: 1 why my code output will be zero? (pictured above)
2 is the best in my code changes, the bottom line is made, can only use cycle and array
3 can explain more would be great


code vegetables chicken + new handball goals you [I]
  • Related