Home > Back-end >  I can't find this mistake
I can't find this mistake

Time:10-06




Code for a few mistakes, I really can't find where is the
 # include & lt; Stdio. H> 


Int main ()
{
Int chang1; The scanf (" % d ", & amp; Chang1); Int a [chang1];
for(int i=0; i{
The scanf (" % d ", & amp; A [I]); }
Printf (" DGDFSG ");
Int n; The scanf (" % d ", & amp; N); Int b [n].
for(int i=0; iThe scanf (" % d ", & amp; B [I]); }
Int c [20]; Int count=0;
Int I, j;

For (I=0; i{
Int flag=1;
For (j=0; i{
If ([j] a [I]==b) flag=0;
}
If (flag) c=[count++] a [I];
}

For (I=0; i{int flag=1;
For (j=0; i{
If (b==[I] a [j]) flag=0;
}
If (flag) c [count++] [I]=b;
}
Printf (" % d, c [0]).
for(int i=1; i{int flag=1;
for(int j=0; j{
If (c==c [j] [I]) flag=0;
}

If (flag) printf (" % d ", [I] c);

}

}

Usercode/script. Sh: line 62:11 Segmentation fault $output - & lt; "/usercode/inputFile
"

Problem description
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:
1 3 5-15 June 4

CodePudding user response:

Line 10 of them are my test

CodePudding user response:

The dynamic array can do this with? Int a [chang1]; Int b [n].

CodePudding user response:

 # include & lt; Stdio. H> 
#include

Int main ()
{
Int chang1;
The scanf (" % d ", & amp; Chang1);
//int a [chang1];
Int * a=(int *) malloc (sizeof (int) * chang1);
for(int i=0; i{
The scanf (" % d ", & amp; A [I]);
}
Printf (" DGDFSG ");
Int n;
The scanf (" % d ", & amp; N);
//int b [n].
Int * b=(int *) malloc sizeof (int) * n);
if (! B)
exit(0);

for(int i=0; iThe scanf (" % d ", & amp; B [I]);
}
Int c [20];
Int count=0;
Int I, j;

For (I=0; i{
Int flag=1;
For (j=0; i{
If ([j] a [I]==b) flag=0;
}
If (flag) c=[count++] a [I];
}

For (I=0; i{int flag=1;
//for (j=0; iFor (j=0; j{
If (b==[I] a [j]) flag=0;
}
If (flag) c [count++] [I]=b;
}
Printf (" % d, c [0]).

for(int i=1; i{int flag=1;
for(int j=0; j{
If (c==c [j] [I]) flag=0;
}

If (flag) printf (" % d ", [I] c);

}

}

For your reference ~

Try this program ~

Variable-length array C language does not support, only supports fixed length of an array, so want to use dynamic application space, in addition, add free advice

CodePudding user response:

I know, I, j, there is confusion

CodePudding user response:

Compile time plus - g, in the run GDB, period of mistakes look at the trace, you'll know where, another c99 is support variables used to define an array
  • Related