参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String in = scanner.nextLine(); System.out.print(p(in)); } public static String p(String in) { String s = in.toUpperCase(); String res = "("; int cnt = 1; for(int i = 1; i < s.length(); i++) { if(s.charAt(i) == s.charAt(i - 1)) cnt++; else { res += s.charAt(i - 1) + "," + cnt + ")("; cnt = 1; } if(i == s.length() - 1) { res += s.charAt(i) + "," + cnt + ")"; } } return res; } }
0.0分
5 人评分
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:565 |
点我有惊喜!你懂得!浏览:3889 |
C语言训练-求素数问题 (C语言代码)浏览:963 |
C语言训练-谁家孩子跑最慢* (C语言代码)浏览:1508 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:517 |
剔除相关数 (C语言代码)浏览:1015 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:970 |
C语言训练-排序问题<1> (C语言代码)浏览:601 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:543 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:624 |