본문 바로가기

코딩테스트(백준)

(46)
[백준] 2798번: 블랙잭 -JAVA - 사좋배 공유 문제 답 : import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int count = sc.nextInt(); int number =sc.nextInt(); int sum=0; int NUM[]= new int[count]; int gap1; int gap2=number; int temp = 0; for(int i=0;i
[백준] 1748번: 수 이어 쓰기 1 -JAVA - 사좋배 공유 문제 답 : import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int number= sc.nextInt(); int cnt=1; int temp=0; int lenght=10; for(int i=1;i
[백준] 4948번: 베르트랑 공준 -JAVA - 사좋배 공유 답 : import java.util.Scanner; public class Main { public static void main(String[] args) { int[] arr =new int[200000]; int i=0; int cnt=0; int count=0; Scanner sc = new Scanner(System.in); int number=1; while(number!=0) { number=sc.nextInt(); arr[i]=number; i++; } for(int j=0;j
[백준] 2960번: 에라토스테네스의 체 -JAVA - 사좋배 공유 답: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc1= new Scanner(System.in); int N=sc1.nextInt(); int K=sc1.nextInt(); int [] arr = new int [N-1]; int [] temparr = new int[N-1]; int temp; int cnt=0; for(int i=0;i
[백준] 10872번: 팩토리얼 -JAVA - 사좋배 공유 답 : import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int number; int temp=1; number=sc.nextInt(); for(int i=number;i>0;i--) { temp=temp*i; } System.out.println(temp); } }
[백준] 2577번: 숫자의 개수 -JAVA - 사좋배 공유 답 import java.util.Scanner; public class Main { public static void main(String[]args) { Scanner sc = new Scanner(System.in); int []arr = new int[10]; int temp; int count=0; int flag=0; int number=1; for(int i=0;i=1;i++) { arr[i]=number%10; number=number/10; count++; } for(int i=0;i