码迷,mamicode.com
首页 > 其他好文 > 详细

代码里报错的部分要怎么修改呢

时间:2018-03-23 01:09:50      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:style   java   amp   程序   system   sys   har   span   next   

程序代码:

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();
    }

}

代码里报错的部分要怎么修改呢

标签:style   java   amp   程序   system   sys   har   span   next   

原文地址:https://www.cnblogs.com/sad89683/p/8627677.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!