Home > Back-end >  C language to find two arrays of common elements
C language to find two arrays of common elements

Time:12-10

# include "stdio.h"
Int main ()
{
Int a, b, c, d, e, f, g;
The scanf (" % d ", & amp; A);
B=0;
Int z [a];
While (b{
The scanf (" % d ", & amp; Z [b]);
B++;
}

The scanf (" % d ", & amp; C);
D=0;
Int x [c];
While (d{
The scanf (" % d ", & amp; X [d]);
D++;
}

[a], int q w [c];
W [0]=z [0];
D=0;

For (e=1; E{
For (g=0; G<=d; G + +)
{
If (z==w [g] [e])
break;
If (g==d)
{
D++;
W=z [d] [e];
}
}
}


Q [0]=x [0];
F=0;
For (e=1; E{
For (g=0; G<=f; G + +)
{
If (x==q [e] [g])
break;
If==f (g)
{
f++;
Q=x [f] [e];
//printf (" % d ", q [f]);
}
}
}
A=0;
For (e=0; E<=d; E++)
{
For (g=0; G<=f; G + +)
{
If (w==q [e] [g])
break;
If==f (g)
Printf (" % d ", w [e]); }


}
For (g=0; G<=f; G + +)
{
For (e=0; E<=d; E++)
{
If (w==q [e] [g])
break;

If (e==d)
{

If (a==0)
{printf (" % d ", q [g]);
A=1; }
The else printf (" % 2 d ", q [g]); }}
}
printf("\n");

//printf (" f d====% d % d ", f, d);
}
Above is my code, submit the said is format error, I vomitted, which really wrong?



Topics are as follows:
7-42 find not two array elements common to
Given two integer arrays, subject requirements to find neither joint element,

Input format:
Input respectively in the two lines is given two integer array, each row gives positive integer N (20) or less, followed by N integers, separated by Spaces,

The output format:
In a line according to the figures given in the order of the output is not two arrays of elements, separated by Spaces between Numbers, but at the end of the line can not have redundant Spaces, subject to ensure there are at least one of these Numbers, the same digital output that is not repeated,

Input the sample:
10 for 3 to 5 2 8 0 3 5-15 September 100
11 June 4 2-5 6 to 9 0 100 8 August 1
The output sample:
3 5-15 June 4 1

CodePudding user response:

C language array lengths must be determined is a constant value,
Int a, b, c, d, e, f, g;
The scanf (" % d ", & amp; A);
B=0;
Int z [a];
Define an array is not so

CodePudding user response:

Format error mean your output format is not in conformity with the requirements of the subject,
  • Related