这题我开始就觉得花很多时间,最后几分钟写出来的 用的很蠢的string import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ String in = sc.nextLine(); int left = 0; if(in.startsWith("-")){ left = 1; } int start = in.indexOf('.'); int len = start == -1 ? in.length() - 1 : start - 1; String res = "."; int count = 1; for(int i = len; i >= left; i--){ if(count == 3 && i != left){ res = "," + in.charAt(i) + res; count = 1; }else{ res = in.charAt(i) + res; count++; } }
点赞 6

相关推荐

此在夜:我之前也是这样,然后四五天之后进入HR面状态,发了测评,做完三十天后约了HR面
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务