0
The problem is:
Write an algorithm that reads 3 vectors
A[1..10], B[1.10] e C[1..10]
and write the elements that are in A and B (intersection) but are not in C. Write the values in the order they appear in vector A. The three vectors should be read separately (first, all the vector A, after vector B and finally vector C).
My solution (which is not running):
#include <stdio.h>
int main()
{
int A[10], B[10], C[10], i, j, k;
for (i=0; i<=9; i++)
scanf ("%d",&A[i]);
for (j=0; j<=9; j++)
scanf ("%d",&B[j]);
for (k=0; k<=9; k++)
scanf ("%d",&C[k]);
for (i=0; i<=9; i++)
{
for (j=0; j<=9; j++)
{
if (A[i]==B[j])
{
for (k=0; k<=9; k++)
{
if (A[i]!=C[k])
printf ("%d\n",C[k]);
}
}
}
}
}
Where is the error and how can I correct it?
It hasn’t worked yet, but it has helped! Thank you!
– Luis Pedro T. B.
had to take the
if
inside the loop... I edited the answer– Dudaskank