java Run-length encoding

后端 未结 5 1298
臣服心动
臣服心动 2020-12-06 08:38

I have no idea how to start my assignment.

We got to make a Run-length encoding program,

for example, the users enters this string:

aaaaPPPrrrrr

5条回答
  •  失恋的感觉
    2020-12-06 09:16

    import java.util.Scanner;
    /**
     * @author jyotiv
     *
     */
     public class RunLengthEncoding {
     /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("Enter line to encode:");
        Scanner s=new Scanner(System.in);
        String input=s.nextLine();
                int len = input.length();
                int i = 0;
                int noOfOccurencesForEachChar = 0;
                char storeChar = input.charAt(0);
    
                String outputString = "";
                for(;i

    I have tried this one. It will work for sure.

提交回复
热议问题