Sort by

recency

|

3428 Discussions

|

  • + 0 comments

    this is how I did it using string slicing and steps, n = int(input())

    for _ in range(n): s = input() print(s[::2],s[1::2])

  • + 0 comments

    input and output olution.cpp:8:5: error: expected unqualified-id before numeric constant int 1*0; ^ Solution.cpp:9:1: error: ‘innt’ does not name a type; did you mean ‘int’? innt sum *0 ^~~~ int Solution.cpp:13:4: error: ‘count’ does not name a type; did you mean ‘round’? count:<

  • + 0 comments

    input and output

  • + 0 comments
            Scanner sc = new Scanner(System.in);
            int testCase = sc.nextInt();
    
                for (int i = 0; i < testCase; i++) {
                    String str = sc.next();
                    for (int j = 0; j < str.length(); j++) {
                            if(j % 2 ==0){
                                    System.out.print(str.charAt(j));
                            }
                    }
                    System.out.print(' ');
                    for (int k = 0; k < str.length(); k++) {
                            if(k % 2 ==1){
                                    System.out.print(str.charAt(k));
                            }
                    }
                    System.out.println();
            }
    
  • + 0 comments
    t = int(input())
    
    for _ in range(t):
        S = input().strip()
        even_index = []
        odd_index = []
    
        for i, char in enumerate(S):
            if i % 2 == 0:
                even_index.append(char)
            else:
                odd_index.append(char)
    
        print("".join(even_index), "".join(odd_index))