0
c programming common element in array
input output 5 2 4 5 1 2 2 4 5 8 1 2 2 4 6 7 8 5 #include <stdio.h> int main() { int n,m; int a[10]; int b[10]; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a[i]); } scanf("%d",&m); for(int i=0;i<m;i++) { scanf("%d",&b[i]); } for(int i=0;i<n;i++) {for(int j=1;j<n;j++) { if(a[i]==a[j]) a[j]=0; } } for(int i=0;i<n;i++) {for(int j=0;j<m;j++) { if(a[i]==0); { break; } if(a[i]==b[j]) { printf("%d",a[i]); break;} } } return 0; }
2 Respostas
+ 3
Please save that code in SoloLearn and share the saved code link instead. More comfortable for analysis. And you have more room to type to describe your problem so people can understand better.
Here's how, in case you didn't know ...
https://www.sololearn.com/post/75089/?ref=app