문제 풀이/자바

public class Banjo { public static String areYouPlayingBanjo(String name) { if(name.startsWith("r") || name.startsWith("R")) { return name + " plays banjo"; } else { return name + " does not play banjo"; } } }
package com.codewars.hwtdstrngls; public class RoundToTheNextMultipleOf5 { public static int roundToNext5(int n) { while( n % 5 != 0) n++; return n; } } 몇 줄 안 되는데 여전히 시간이 오래 걸린다 백준 같은 사이트 문제는 더 오래 걸려서 시간이 있는 날 없는 날 백준 / 코드워즈를 왔다 갔다 하는 중
public class Solution { public static String repeatStr(final int repeat, final String string) { String result = ""; if (repeat > 0) { for (int i = 0; i < repeat; i++) { result += string; } } return result; } }
public class NoBoring { public static int noBoringZeros(int n) { if(n == 0) { return n; } while(n % 10 == 0) { n /= 10; } return n; } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for(int i=1; i
N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int num = Integer.parseInt(br.readLine()); for(int i=1; i
public class Kata { public static String switchItUp(int number) { String[] arr = {"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; String arr1 = arr[number]; return arr1; } }
public class TwiceAsOld{ public static int TwiceAsOld(int dadYears, int sonYears){ //TODO: Add code here int years = dadYears - 2 * sonYears; if (years > 0) { return years; } return years * (-1); } }
public class Kata{ public static double find_average(int[] array){ double avr = 0; for(int i = 0; i < array.length; i++){ avr += array[i]; } double result = avr / array.length; return result; } }
public class SumArray { public static double sum(double[] numbers) { double res = 0; for(int i = 0; i < numbers.length; i++) res += numbers[i]; return res; } }
ssoyul
'문제 풀이/자바' 카테고리의 글 목록 (2 Page)