-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexam.java
More file actions
26 lines (25 loc) · 785 Bytes
/
Copy pathexam.java
File metadata and controls
26 lines (25 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;
class exam {
public static void main (String[] args) {
String[] strings = new String[2];
Scanner scan = new Scanner(System.in);
int friendCorrect = scan.nextInt();
scan.nextLine();
for(int j = 0; j < 2; j++) {
strings[j] = scan.nextLine();
}
scan.close();
int match = 0;
for (int i = 0; i < strings[0].length(); i++) {
if (strings[0].charAt(i) == strings[1].charAt(i)) {
match++;
}
}
if (match > friendCorrect) {
System.out.println(friendCorrect + (strings[0].length() - match));
}
else {
System.out.println(match + (strings[0].length() - friendCorrect));
}
}
}