Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Triacontakai
- * Period 6
- * This program compares 2 arrays and recognizes how many numbers
- * there are in the same place in both arrays
- */
- public class TriacontakaiSimilarity{
- public static void main(String[] args){
- System.out.println("Welcome!\n");
- int[] a1 = {5, 9, 4, 2, 0, 7, 3, 1, 8, 2};
- int[] a2 = {9, 2, 5, 2, 8, 7, 4, 2, 8, 2};
- int sim = 0;
- System.out.print("First Array: ");
- for(int i = 0; i <= 9; i++){
- System.out.print(a1[i] +" ");
- }
- System.out.print("\nSecond Array: ");
- for(int i = 0; i <= 9; i++){
- System.out.print(a2[i] +" ");
- }
- for(int i = 0; i <= 9; i++){
- if(a1[i] == a2[i]){
- sim++;
- }
- }
- System.out.println("\n\nThere are "+ sim +" numbers in the same spot.");
- }
- }
Add Comment
Please, Sign In to add comment