-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckCode.java
More file actions
29 lines (29 loc) · 781 Bytes
/
CheckCode.java
File metadata and controls
29 lines (29 loc) · 781 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
27
28
29
import java.util.*;
public class CheckCode {
@SuppressWarnings("unused")
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
sc.nextLine();
String str = sc.nextLine();
if (str.charAt(a)!='-') {
System.out.println("No");
System.exit(0);
}
int len = str.length();
boolean ch = false;
for (int i = 0; i < len; i++) {
if ((str.charAt(i)<'0' || str.charAt(i)>'9') && i != a) {
ch = true;
}
}
if (ch==false) {
System.out.println("Yes");
}
else{
System.out.println("No");
}
sc.close();
}
}