pages:
  • 1
farooq SAYS

why?runtime?

please help me guys

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
    Scanner cin = new Scanner(System.in);
    while(true){
        int num = cin.nextInt();
        if(num == 0 || num > 100)
            System.exit(num);
        String[] s = new String[num];
        for(int h = 0 ; h < num ; h++){
            s[h] = cin.next();
        }
        int n , i , j , z;
        int count;
        char x;
        String y;
        for(int g = 0 ; g < num ; g++){
            n = s[g].length();
            if(n > 100)
                break;
            i = 0;
            j = 1;
            z = 0;
            count = 1;
            y = "";
            while(i < n){
                x = s[g].charAt(i);
                if((int) x < 65 || (int) x > 90)
                    System.exit(0);
                if(i == n - 1){
                    y += x;
                    break;
                }
                while(x == s[g].charAt(i + j)){
                    count++;
                    j++;
                    if(i + j >= n)
                        break;
                }
                if(count == 1)
                    y += x;
                else
                    y = y + count + x;

                z += j;
                i = z;
                j = 1;
                count = 1;
            }
            System.out.println(y);
        }
    }

}

}

AMiR SAYS

Hello!

Just try to comment while (true) { and the corresponding } at the end.

You should just read one integer n and then n strings.

farooq SAYS

Hi!

you help me so good!

Thank you