解题思路:
注意事项:
参考代码:
package arrLast; //题目 2873: 字符串p型编码 import java.util.Scanner; public class t_2873 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); String str=sc.next(); int cont=0;char []arr=str.toCharArray(); char temp=arr[0]; for(int i=0;i<arr.length;i++) { if(arr[i]==temp) cont++; else{ System.out.print(cont+""+temp);temp=arr[i]; cont=1;}} temp=arr[arr.length-1];cont=0; for(int i=arr.length-1;i>=0;i--) { if(arr[i]==temp) cont++; else break; } System.out.print(cont+""+temp);}}
0.0分
0 人评分
大神老白 (C语言代码)浏览:645 |
printf基础练习2 (C语言代码)浏览:745 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:546 |
C语言训练-尼科彻斯定理 (C语言代码)浏览:469 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:449 |
WU-判定字符位置 (C++代码)浏览:1406 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:534 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:622 |
1908题解浏览:640 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:537 |