为什么我输出和预期输出一样,但是不通过啊😥
import java.nio.Buffer;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String temp;
for (int i = 0; i != n; i++) {
temp = sc.next();
StringBuffer buffer = new StringBuffer(temp);
if (buffer.charAt(0) > '2' || (buffer.charAt(0) == '2' && temp.charAt(1) >= '5')) {
buffer.setCharAt(0, '0');
}
if (buffer.charAt(3) > '6' || (buffer.charAt(3) == '6' && temp.charAt(4) != '0')) {
buffer.setCharAt(3, '0');
}
if (buffer.charAt(6) > '6' || (buffer.charAt(6) == '6' && temp.charAt(7) != '0')) {
buffer.setCharAt(6, '0');
}
String s = buffer.toString();
System.out.println(s);
}
}
}
import java.nio.Buffer;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String temp;
for (int i = 0; i != n; i++) {
temp = sc.next();
StringBuffer buffer = new StringBuffer(temp);
if (buffer.charAt(0) > '2' || (buffer.charAt(0) == '2' && temp.charAt(1) >= '5')) {
buffer.setCharAt(0, '0');
}
if (buffer.charAt(3) > '6' || (buffer.charAt(3) == '6' && temp.charAt(4) != '0')) {
buffer.setCharAt(3, '0');
}
if (buffer.charAt(6) > '6' || (buffer.charAt(6) == '6' && temp.charAt(7) != '0')) {
buffer.setCharAt(6, '0');
}
String s = buffer.toString();
System.out.println(s);
}
}
}
全部评论
相关推荐
01-08 14:35
门头沟学院 测试工程师 点赞 评论 收藏
分享
2024-11-21 14:17
惠州学院 嵌入式软件开发 点赞 评论 收藏
分享