I'm trying to solve a problem early on which is as follows:
A school wants to know if there are disciplines Logic and e Programming language. Enter the numbers of the students that study the Logic in a vector at most of 5 students. Enter the enrollment numbers of the students taking the course Language in another vector, up to 5 students. Display the which appears in both vectors.
It's still running, but when I put numbers out of order it's bugging. If you can help me, thank you, because I am breaking my head on this issue and it is catching me to finish the rest of the others, seems to be lazy to think, but I have been locked in this question since early.
From-already thank you
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int i, a;
int mat1[6], mat2[6];
int main(void){
setlocale(LC_ALL, "Portuguese");
for(i=0 ; i<5; i++){
printf("DIGITE AS MATRÍCULAS DOS ALUNOS DE LÓGICA DE PROGRAMAÇÃO: ");
scanf("%d", &mat1[i]);
}
printf("\n");
for(i=0; i<5; i++){
printf("DIGITE AS MATRÍCULAS DOS ALUNOS DE LINGUAGEM DE PROGRAMAÇÃO: ");
scanf("%d", &mat2[i]);
}
printf("\n");
for(i=0; i<5; i++){
for(a=5; a>=0; a--)
{
if(mat1[i] == mat2[a] || mat1[a] == mat2[i]) printf("AS MATRÍCULAS IGUAIS SÃO: %d\n", mat1[i]);
}
}
return 0;
}
Running the program: