Last active
September 22, 2020 12:15
-
-
Save JoeUnsung/1de94043ff336cdedb54157c5990e5f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 입출력 (11/11) : 곱셈 | |
package playGround; | |
import java.util.*; | |
public class testJava{ | |
public static void main(String[] args){ | |
Scanner temp = new Scanner(System.in); | |
int[] result_arr = new int[3]; | |
int x_int = Integer.parseInt(temp.nextLine()); | |
String y_char = temp.nextLine(); | |
for(int i = 0; i <= 2; i++){ | |
result_arr[i] = x_int * Integer.parseInt(String.valueOf(y_char.charAt(2-i))); | |
System.out.println(result_arr[i]); | |
} | |
int sum_num = 0; | |
for(int i = 0; i <= 2; i++){ | |
sum_num += result_arr[i] * Math.pow(10, i); | |
} | |
System.out.println(sum_num); | |
} | |
} | |
// if 문제 - 1 | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args){ | |
Scanner temp = new Scanner(System.in); | |
int x = temp.nextInt(); | |
if(x/4 == 0 & x/100 != 0){ | |
System.out.println(1); | |
} else if(x/400 == 0){ | |
System.out.println(1); | |
} else{ | |
System.out.println(0); | |
} | |
} | |
} | |
// if 문제 - 2 | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args){ | |
Scanner temp = new Scanner(System.in); | |
int x = temp.nextInt(); | |
int y = temp.nextInt(); | |
if(x>0 & y>0){ | |
System.out.println(1); | |
} else if (x<0 & y>0){ | |
System.out.println(2); | |
} else if (x<0 & y<0){ | |
System.out.println(3); | |
} else { | |
System.out.println(4); | |
} | |
} | |
} | |
// if 문제 - 3 | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args){ | |
Scanner temp = new Scanner(System.in); | |
int x = temp.nextInt(); | |
int y = temp.nextInt(); | |
if (y >= 45){ | |
System.out.printf("%d %d", x, y-45); | |
} else if (x == 0){ | |
System.out.printf("%d %d", 23, 60+(y-45)); | |
} else { | |
System.out.printf("%d %d", x-1, 60+(y-45)); | |
} | |
} | |
} | |
// For문 문제 - 1 | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args){ | |
Scanner temp = new Scanner(System.in); | |
int x = temp.nextInt(); | |
int[] list_a = new int[x]; | |
int[] list_b = new int[x]; | |
for(int i = 0; i < x; i++){ | |
list_a[i] = temp.nextInt(); | |
list_b[i] = temp.nextInt(); | |
} | |
for(int i = 0; i < x; i++){ | |
System.out.println(list_a[i]+list_b[i]); | |
} | |
} | |
} | |
// for - 2 | |
import java.io.*; | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args) throws IOException { | |
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); //읽는 라인 | |
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); //출력 라인 | |
int x = Integer.parseInt(bf.readLine()); | |
for (int i = 0; i < x; i++) { | |
String s = bf.readLine(); // String으로 라인별로 입력받 | |
StringTokenizer st = new StringTokenizer(s); | |
int a = Integer.parseInt(st.nextToken()); //첫번째 호출 | |
int b = Integer.parseInt(st.nextToken()); //두번째 호출 | |
bw.write(String.valueOf(a+b)); | |
bw.newLine(); | |
} | |
bw.flush(); | |
bw.close(); | |
} | |
} | |
// for -3 | |
import java.io.*; | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args) throws IOException { | |
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); //읽는 라인 | |
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); //출력 라인 | |
int x = Integer.parseInt(bf.readLine()); | |
for (int i = 0; i < x; i++) { | |
String s = bf.readLine(); // String으로 라인별로 입력받 | |
StringTokenizer st = new StringTokenizer(s); | |
int a = Integer.parseInt(st.nextToken()); //첫번째 호출 | |
int b = Integer.parseInt(st.nextToken()); //두번째 호출 | |
bw.write("Case #"+String.valueOf(i+1)+": "+String.valueOf(a+b)); | |
bw.newLine(); | |
} | |
bw.flush(); | |
bw.close(); | |
} | |
} | |
// while - 1 | |
import java.io.*; | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args) throws IOException { | |
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); //읽는 라인 | |
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); //출력 라인 | |
while(true){ | |
String s = bf.readLine(); // String으로 라인별로 입력받기 | |
StringTokenizer st = new StringTokenizer(s); | |
int a = Integer.parseInt(st.nextToken()); //첫번째 호출 | |
int b = Integer.parseInt(st.nextToken()); //두번째 호출 | |
if (a+b == 0){ | |
break; | |
} else{ | |
bw.write(String.valueOf(a+b)); | |
bw.newLine(); | |
continue; | |
} | |
} | |
bw.flush(); | |
bw.close(); | |
} | |
} | |
// while - 2 | |
import java.io.*; | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args) throws IOException { | |
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); //읽는 라인 | |
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); //출력 라인 | |
String s = " "; | |
while((s = bf.readLine()) != null){ | |
// String s = bf.readLine(); // String으로 라인별로 입력받기 | |
StringTokenizer st = new StringTokenizer(s); | |
int a = Integer.parseInt(st.nextToken()); //첫번째 호출 | |
int b = Integer.parseInt(st.nextToken()); //두번째 호출 | |
if (false){ | |
break; | |
} else{ | |
bw.write(String.valueOf(a+b)); | |
bw.newLine(); | |
continue; | |
} | |
} | |
bw.flush(); | |
bw.close(); | |
} | |
} | |
// Def - 1 | |
public class Test { | |
long sum(int[] a) { | |
long ans = 0; | |
int len_a = a.length; | |
for(int i = 0; i < len_a; i++){ | |
ans += a[i]; | |
} | |
return ans; | |
} | |
} | |
// Array - 1 | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args){ | |
Scanner temp = new Scanner(System.in); | |
int[] array_num = new int[10]; | |
for (int i = 0; i < 10; i++){ | |
array_num[i] = temp.nextInt()%42; | |
// System.out.println("42로 나눈 나머지" + array_num[i]); | |
} | |
// System.out.println("array_num 결과값 "); | |
// System.out.println("------------------"); | |
// for (int i = 0; i < 10; i++) { | |
// System.out.println(array_num[i]); | |
// } | |
int[] distinctNum_array = {43,43,43,43,43,43,43,43,43,43}; | |
int cnt = 0; int result_num = 0; | |
for (int i = 0; i < 10; i++){ | |
for (int j = 0; j < 10; j++){ | |
if (distinctNum_array[j] == array_num[i]){ | |
// System.out.println("중복이 있을 경우 : " + array_num[i] + " " + i); | |
cnt += 1; | |
} | |
} | |
if (cnt == 0){ | |
distinctNum_array[i] = array_num[i]; | |
result_num += 1; | |
} | |
cnt = 0; | |
} | |
// System.out.println("distinctNum의 결과"); | |
// for (int i = 0; i < 10; i++) { | |
// System.out.println(distinctNum_array[i]); | |
// } | |
System.out.println(result_num); | |
} | |
} | |
// array - 2 | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args){ | |
Scanner temp = new Scanner(System.in); | |
int iterNum = temp.nextInt(); | |
int[] array = new int[iterNum]; | |
for (int i = 0; i < iterNum ; i++){ | |
array[i] = temp.nextInt(); | |
} | |
int minNum = 9999999; int maxNum = -9999999; | |
for (int i = 0; i < iterNum ; i++){ | |
if (array[i] > maxNum){ | |
maxNum = array[i]; | |
} | |
if (array[i] < minNum){ | |
minNum = array[i]; | |
} | |
} | |
System.out.print(minNum+" "+maxNum); | |
} | |
} | |
// Array - 3 | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args){ | |
Scanner temp = new Scanner(System.in); | |
int iterNum = 9; | |
// 입력 | |
int[] array = new int[iterNum]; | |
for(int i = 0; i < iterNum; i++){ | |
array[i] = temp.nextInt(); | |
} | |
// 최대값과 위치 탐색 | |
int maxNum = 0; int index = 99999; | |
for (int i = 0; i < iterNum; i++){ | |
if (maxNum < array[i]){ | |
maxNum = array[i]; | |
index = i; | |
} | |
} | |
// 결과 출력 | |
System.out.println(maxNum); | |
System.out.println(index+1); | |
} | |
} | |
// Array - 4 | |
import java.util.*; | |
public class Main{ | |
public static void main (String[] args){ | |
Scanner temp = new Scanner(System.in); | |
// 입력 받기 | |
int[] array = new int[2]; | |
array[0] = temp.nextInt(); | |
array[1] = temp.nextInt(); | |
// Reverse | |
String[] reverseNum = new String[3]; | |
for (int i = 0; i < 2; i++) { | |
reverseNum[0] = Integer.toString(array[i]/100); | |
reverseNum[1] = Integer.toString((array[i]/10)%10); | |
reverseNum[2] = Integer.toString(array[i]%10); | |
array[i] = Integer.parseInt(reverseNum[2]+reverseNum[1] + reverseNum[0]); | |
} | |
// 큰 수 판별 | |
int answerNum = 0; | |
if (array[0] > array[1]) { | |
answerNum = array[0]; | |
} else { | |
answerNum = array[1]; | |
} | |
// 출력 | |
System.out.println(answerNum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment