求助,代码里报错的部分要怎么修改呢
程序代码:
import java.util.Scanner; public class text { public static void main(String[] args) { Scanner in=new Scanner(System.in); while(in.hasNext()){ String s = in.next(); char type = s.charAt(0); String[] str=new String[100]; if(type == 'C'){ int len = str.length; int cnt = 1; for(int i = 0;i < len;i++){ if(str[i] == str[i+1]){ cnt++; }else{ if(cnt>1){ System.out.printf("%d",cnt); } System.out.printf("%c",str[i]); cnt = 1; } } }else{ int len = str.length; int cnt = 0; for(int i = 0;i < len;i++){ if(str[i]<='9'&&str[i]>='0'){ cnt*=10; cnt+=str[i]-'0'; }else{ if(cnt == 0){ System.out.printf("%c",str[i]); }else for(int j = 0;j < cnt;j++){ System.out.printf("%c",str[i]); } cnt = 0; } } } } in.close(); } }