Skip to content

Instantly share code, notes, and snippets.

@gmfc
Forked from RunoFawkes/Vetores2.java
Created May 27, 2013 13:02
Show Gist options
  • Select an option

  • Save gmfc/5656951 to your computer and use it in GitHub Desktop.

Select an option

Save gmfc/5656951 to your computer and use it in GitHub Desktop.
import javax.swing.JOptionPane;
public class Vetores2 {
public static void main(String[] args) {
int a[] = {3, 10, 4, 2, 8};
int[] b = {10, 4, 12, 3, 23, 1, 8};
int[] c = new int[(int)Math.min(a.length, b.length)];
int i=0;
for(int f=0;f<a.length;f++){
for(int k=0;k<b.length;k++){
if(a[f]==b[k]){
c[i] = a[f];
i++;
}
}
}
for (int x=0; x<i; x++){
System.out.println(c[x]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment