参考代码:
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语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:572 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:579 |
P1002 (C语言代码)浏览:973 |
【魔板】 (C++代码)(时间超限,希望会的帮我改正一下)浏览:740 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:569 |
DNA (C语言代码)浏览:736 |
勾股数 (C语言代码)浏览:799 |
C语言训练-自守数问题 (C语言代码)浏览:740 |
敲七 (C语言代码)浏览:2700 |
1134题解(求分析)浏览:724 |