스파르타 57

18_정수 내림차순으로 배치하기_개인 과제 진행 Lv3 도전_25.1.7(화)

코트카타20) 정수 내림차순으로 배치하기나의 풀이버블정렬...을 써보려고 했는데... 잘 안 되어서 sort기능을 사용해서 풀었다.import java.util.*;import static java.lang.Long.parseLong;class Solution { public long solution(long n) { long answer = 0; String strN = "" + n; Long[] longArr = new Long[strN.length()]; for (int i = 0; i  Lv3  트러블슈팅제네릭지름길로 가려고 하다보니 엉망진창이다.그래서 다시 해당 내용을 찬찬히 복습하기로 했다. 제네릭의 장점1. 타입 안정성을 제공한다.2. ..

17_정수 제곱근 판별_개인 과제 진행 Lv3 도전_25.1.6(월)

코트카타19) 정수 제곱근 판별나의 풀이class Solution { public long solution(long n) { long answer = 0; long x = (long)Math.sqrt(n); answer = (n==Math.pow(x,2))?(long)Math.pow((x+1),2):-1; return answer; }} 매번 if문을 사용하는 것 같아, 이번에는 삼항 연산자를 사용해보았다.만약 x가 n의 제곱근이 아니라면 타입을 double아닌 소수점이 없는 long타입으로 했을 때 값 손실이 발생할 것이다.나는 이를 이용하고자 했다. 형변환을 잘 해야 하는 중요성에 대해 깨닫는 요즘이다. 다른 분들의 풀이class Solut..

16_코트카타 문자열을 정수로 바꾸기_개인 과제 진행_25.1.3(금)

코트카타18) 문자열을 정수로 바꾸기나의 풀이class Solution { public int solution(String s) { int answer = 0; answer = Integer.parseInt(s); return answer; }}복잡하게 생각하려다 함수를 써버렸다... 다른 분들의 풀이public class StrToInt { public int getStrToInt(String str) { boolean Sign = true; int result = 0; for (int i = 0; i 출처:https://school.programmers.co.kr/learn/courses/30/les..

14_코트카타_Java 문법 종합반 1,2,3주차_24.12.31(화)

코트카타16) x만큼 간격이 있는 n개의 숫자나의 풀이import java.util.*;class Solution { public long[] solution(int x, int n) { long[] answer = {}; ArrayList list = new ArrayList(); for (int j = 1; j 사실 값을 구하는 것 자체는 할 수 있었는데list의 개념에 대해 익숙하지 않아서쉽지 않았다. 다른 분들의 풀이import java.util.*;class Solution { public static long[] solution(int x, int n) { long[] answer = new long[n]; answer[..

13_코트카타_팀 프로젝트 발표, 피드백, 회고_학습법 특강_자바의 정석 객체지향_24.12.30(월)

코트카타13) 자릿수 더하기나의 풀이import java.util.*;public class Solution { public int solution(int n) { int answer = 0; int a = 0; int b = n; for(int i=(int)(Math.log10(n)+1);i>=0;i--){ answer += b / Math.pow(10,i); b = b % (int)Math.pow(10,i); } // [실행] 버튼을 누르면 출력 값을 볼 수 있습니다. System.out.println(answer); return answer;..

12_삼항연산자_Git 특강 복습_방명록 코드복습_자바의 정석 객체지향_24.12.27(금)

코트카타11) 홀수와 짝수class Solution { public String solution(int num) { String answer = ""; if(num%2==0){ answer="Even"; } else { answer="Odd"; } return answer; }} 삼항연산자로도 문제를 풀 수 있다.괄호 안의 조건이 참이면 Even, 거짓이면 Odd를 반환하는 것이다.(num % 2 == 0) ? "Even" : "Odd"; 출처 : https://school.programmers.co.kr/learn/courses/30/lessons/12937/solution_groups?la..

10일차_코트카타_자바스크립트 자료형_방명록 삭제기능 구현_24.12.24(화)

코트카타1) 두수의 차public class Ex1 { class Solution { public int solution(int num1, int num2) { int answer = 0; if(num1>=-50000 && num1=-50000 && num2 2) 두수의 곱public class Ex2 { class Solution { public int solution(int num1, int num2) { int answer = 0; if (num1 >= 0 && num1 = 0 && num2   3) 몫 구하기public class Ex3 { class..

TIL 9일차(본 캠프 시작일)_2024.12.23(월)

[왕초보] 코딩이 처음이어도 쉽게 배우는 웹개발 A to Z - 1주차CSS이미지 삽입 시background-image: url('https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg');background-position: center;background-size: cover;마진 줄 때.wrap {width: 300px;margin: 50px auto 0px auto;} 중앙으로 정렬할 때display: flex;flex-direction: column;align-items: center;justify-content: center; margin과 padding만 제대로 알아도 성공한 것 같다.marg..

728x90
반응형