개발 (34) 썸네일형 리스트형 [Algorithm] 팰린드롬 알고리즘 - 문자 대칭 1. 팰린드롬 ex1> 앞에서 읽으나 뒤에서 읽으나 똑같은 단어(회문= 팰린드롬), 문자열을 입력 받아서 입력된 문자가 팰린드롬인지 아닌지 여부를 확인하는 함수를 작성하라. (입력된 문자열이 팰린드롬이면 true 를 리턴하고, 아니면 false 를 리턴해야한다.) c>/Users/kim-yunhee/CLionProjects/uni_study/cmake-build-debug/uni_study #include #include #include int isPalindrome (char* inputStrig); void main (int argc, char** args){ int result; if(argcfor 루프 내부에 존재하는 if 조건문을 보면,루프가 반복될 때마다 비교하는 문자의 위치를 입력된 문자열의.. [JAVA] level1. 나누어 떨어지는 숫자 배열 / Arrays.sort() 나누어 떨어지는 숫자 배열 1. 처음 소스package programmers_uni; class Solution { public static int[] solution(int[] arr, int divisor) { int i; int n=0; int cnt=0; for(i=0;i [JAVA] level1 . 정수 제곱근 판별 / Math.sqrt(n), Math.pow(n,m) -정수 제곱근 판별 1. 제곱근, 거듭제곱 import java.util.Math; sqrt(n); : n의 제곱근 pow(n,m); : n의 3 거듭제곱 or 바로 Math.sqrt(n); Math.pow(n,m); 2. 처음 실패 소스class Solution { public long solution(long n) { long answer = -1; int i; for(i=1;i [JAVA] level1 . 핸드폰 번호 가리기 / substring(), String ""+"" -핸드폰 번호 가리기 1. 처음 시도: StringBuffer 클래스의 replace 사용하려고 했지만 String 타입으로 전환을 해야한다는 문제 때문에 실패StringBuffer answer = new StringBuffer (문자열);Answer.replace(int a, int b, String s); 2. 결국 substring 이용끝에서4글자 전까지for 문을 돌려 “*”을 찍고 String 의 + 성질을 이용 3. 내 소스class Solution { public String solution(String phone_number) { String answer = ""; int n=phone_number.length(); int i; for(i=0;i [JAVA] level1 . 약수의 합 -약수의 합 1. 약수 알고리즘 복습 알고리즘 책 참고해서 다시 작성 (알고리즘 카테고리 링크) 2. 내 소스class Solution { public int solution(int n) { int answer = 0; int i; for(i=1;i [JAVA] level1 . 짝수와 홀수 -짝수와 홀수 1. 내 소스class Solution { public String solution(int num) { String answer = ""; if(num%2==0){ answer = "Even"; } else answer = "Odd"; return answer; }} [JAVA] level1 . 직사각형 별찍기 / 표준 입출력 -직사각형 별찍기 1. 표준 입출력Scanner sc = new Scanner(System.in)int a = sc.nextInt(); System.out.print(); //줄바꿈 따로 없이 출력System.out.println(); //줄바꿈 2. 내 소스import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int i,j; for(i=0;i [JAVA] level1 . 평균 구하기 / int[] arr , arr.length -평균 구하기 1. 내 소스class Solution { public double solution(int[] arr) { double answer = 0; int i; int sum=0; for(i=0;i 이전 1 2 3 4 5 다음