분류 전체보기233 소수(에라토스테네스 체) 소수는 1보다 큰 정수 1과 자기 자신으로만 나누어지는 수로 영어로는 Prime Number 이다. 여기서 말하는 나누기란 자연수로 나누었을 때 나머지가 0인 경우를 의미한다. ex) '1'은 '1보다 큰 정수'가 아니므로 소수가 아니다. '2'는 '1보다 큰 정수'이고 '1과 2 이외의 자연수로 나눌 수 없으므로 소수이다. '3'은 '1보다 큰 정수'이고 '1과 3 이외의 자연수로 나눌 수 없으므로 소수이다. '4'는 '1보다 큰 정수'이지만 '1과 4 이외에도 2로 나누는 것이 가능하므로 소수가 아니다. '5'는 '1보다 큰 정수'이고 1과 5 이외의 자연수로 나눌 수 없으므로 소수이다. 설명 자연수 N이 입력되면 1부터 N까지의 소수의 개수를 출력하는 프로그램을 작성하세요. 만약 20이 입력되면 1.. 2022. 9. 28. isAlphabetic() Determines if the specified character (Unicode code point) is an alphabet. A character is considered to be alphabetic if its general category type, provided by getType(codePoint), is any of the following: or it has contributory property Other_Alphabetic as defined by the Unicode Standard. Params: codePoint – the character (Unicode code point) to be tested. Returns: true if the character is a Uni.. 2022. 9. 28. indexOf() Params: ch – a character (Unicode code point). //유니코드 Returns: the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur. 파라미터 : ch - 문자 리턴값 : 객체에 해당하는 문자열에 첫번째로 존재하는 문자의 인덱스 또는 해당하는 문자가 없으면 -1을 리턴 public int indexOf(int ch) { return indexOf(ch, 0); } 2022. 9. 27. valueOf() Returns the string representation of the {@code char} array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the returned string. param : data - the character array. // 매개변수 문자배열 return : a {@code String} that contains the characters of the character array. //문자배열의 문자들로 구성된 문자열 public static String valueOf(char data[]) //문자 .. 2022. 9. 27. toCharArray() //반환타입이 char[] 문자 배열 //문자열을 조각내서 문자배열 안에 넣어줌 public char[] toCharArray() { return isLatin1() ? StringLatin1.toChars(value) : StringUTF16.toChars(value); } Params:format – A format string args – Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero.. 2022. 9. 27. charAt() public char charAt(int index)//@Range(from = 0, to = java.lang.integer.MAX_VALUE) 0~2147483647 { if (isLatin1()) { return StringLatin1.charAt(value, index); } else { return StringUTF16.charAt(value, index); } } Returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, and so on, as for array ind.. 2022. 9. 27. scope, static 변수가 선언된 블럭이 그 변수의 사용범위이다. public class ValableScopeExam{ // 전역 변수 int globalScope = 10; // 인스턴스 변수 public void scopeTest(int value)//블럭 바깥에있지만 지역변수 처럼 사용{ //지역변수 int localScope = 10; System.out.println(globalScope); System.out.println(localScpe); System.out.println(value); } public static void main(String[] args) { System.out.println(globalScope); //오류 // 인스턴스화 해서 사용하거나 static 이용 System.out.prin.. 2022. 9. 27. 2. 단어 뒤집기 2. 단어 뒤집기 설명 N개의 단어가 주어지면 각 단어를 뒤집어 출력하는 프로그램을 작성하세요. 입력 첫 줄에 자연수 N(3 2022. 9. 27. 1.문자 찾기 설명 한 개의 문자열을 입력받고, 특정 문자를 입력받아 해당 특정문자가 입력받은 문자열에 몇 개 존재하는지 알아내는 프로그램을 작성하세요. 대소문자를 구분하지 않습니다.문자열의 길이는 100을 넘지 않습니다. 입력 첫 줄에 문자열이 주어지고, 두 번째 줄에 문자가 주어진다. 문자열은 영어 알파벳으로만 구성되어 있습니다. 출력 첫 줄에 해당 문자의 개수를 출력한다. 예시 입력 1 Computercooler c 예시 출력 1 2 1. 첫번째 방법 import java.util.Scanner; public class Main { public int solution(String str, char t) { int result = 0 ; //입력받은 문자열, 문자 대문자로 변환 str = str.toUpperCas.. 2022. 9. 26. Java 과제 1. 출력 결과를 5로 기대했는데 4가 출력된 이유 public class Exam1 { public static void main(String[] args) { int var1 = 5; int var2 = 2; //자바 연산 에서 일반적인 계산과 달리 분수/소수 계산을 하지 않고 몫에 해당하는 값만 반환함 double var3 = var1/var2;// 값은 2.0 // var3 = 2.0, var2 = 2 -> 2.0 * 2 = 4.0 -> 형변환(casting) -> (int)(4.0) = 4 int var4 = (int)(var3*var2); //값은 4 System.out.println(var4); // 4가 출력 } } 2. 다음 코드를 실행했을 때 출력 결과는 무엇입니까? public cla.. 2022. 9. 23. web 인증 방식 2022. 9. 22. 회원관리 비즈니스 요구사항 2022. 9. 17. 이전 1 ··· 8 9 10 11 12 13 14 ··· 20 다음