HR30 Day 6: Let's Review

1 개요[ | ]

Day 6: Let's Review
해커랭크 30 Days of Code
문제 풀이
0-9 Day e
HR30 Day 0: Hello, World.

HR30 Day 1: Data Types

HR30 Day 2: Operators

HR30 Day 3: Intro to Conditional Statements

HR30 Day 4: Class vs. Instance

HR30 Day 5: Loops

HR30 Day 6: Let's Review

HR30 Day 7: Arrays

HR30 Day 8: Dictionaries and Maps

HR30 Day 9: Recursion

2 Java[ | ]

import java.io.*;
import java.util.*;

public class Solution {
    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner in = new Scanner(System.in);
        int TT = in.nextInt();
        in.nextLine();
        for(int t=0; t<TT; t++) {
            char[] chs = in.nextLine().toCharArray();
            for(int i=0; i<chs.length; i+=2) {
                System.out.print(chs[i]);
            }
            System.out.print(" ");
            for(int i=1; i<chs.length; i+=2) {
                System.out.print(chs[i]);
            }
            System.out.println();
        }
    }
}

3 PHP[ | ]

<?php
$_fp = fopen("php://stdin", "r");
fscanf($_fp, "%d\n", $n);
for($t=0; $t<$n; $t++) {
    fscanf($_fp, "%s\n", $str);
    for($i=0; $i<strlen($str); $i+=2) echo $str[$i];
    echo ' ';
    for($i=1; $i<strlen($str); $i+=2) echo $str[$i];
    echo "\n";
}
fclose($stdin);

4 Python[ | ]

T = int(input())
for j in range(T):
    S = input()
    length = len(S)
    for i in range(0,length,2):
        print( S[i], end='' )
    print( ' ', end='' )
    for i in range(1,length,2):
        print( S[i], end='' )
    print()
T = int(input())
for j in range(T):
    S = input()
    even, odd = S[::2], S[1::2]
    print(even + ' ' + odd)

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}