분류 전체보기70 [알고리즘] 선택정렬 알고리즘 선택정렬 JAVA 코드 data[10] : 정렬할 숫자가 저장 될 배열 count : 입력 받은 숫자의 개수가 저장 될 변수 i : 정렬 회전 수, 비교 기준 값이 있는 위치를 지정해 주는 변수 j : 비교 대상이 있는 위치를 지정해주는 변수 k : 자료를 교환할 때 사용할 임시 변수 num : 출력할 때 배열의 위치를 지정해 주는 변수 for문 public class sort_1 { public static void main(String[] args) { int count,i,j,k,num; int data[] = new int[10]; Scanner scan = new Scanner(System.in); for(count=0; count 2022. 4. 23. [프로그래머스] 짝수와 홀수 프로그래머스 1단계 짝수와 홀수 https://programmers.co.kr/learn/challenges 문제 설명 제한 조건 - num은 int 범위의 정수입니다. - 0은 짝수입니다. 풀이 class Solution { public String solution(int num) { String answer; if(num%2==0) answer = "Even"; else answer = "Odd"; return answer; } } 2022. 4. 23. [프로그래머스] x만큼 간격이 있는 n개의 숫자 프로그래머스 1단계 x만큼 간격이 있는 n개의 숫자 https://programmers.co.kr/learn/challenges 문제 설명 풀이 class Solution { public long[] solution(long x, int n) { long[] answer; answer = new long[n]; for(int i=0; i 2022. 4. 23. [프로그래머스] 평균 구하기 프로그래머스 1단계 평균 구하기 https://programmers.co.kr/learn/challenges 문제 설명 풀이 class Solution { public double solution(int[] arr) { double answer = 0; for(int i = 0; i 2022. 4. 23. 이전 1 ··· 12 13 14 15 16 17 18 다음