Programming (136) 썸네일형 리스트형 [Project Euler] Problem 007 1234567891011121314151617181920212223242526272829303132333435363738#include int isPrime(int num); int main(){ int i; int count = 1; for (i = 2; count [Project Euler] Problem 006 수열의 합 공식을 안다면 별다른 알고리즘이 필요 없다. 이를 그대로 출력하기만 하면 된다. 12345678910111213#include #define MAX 100 int main(){ printf("Square of sum: %d\n", ((((MAX)*(MAX + 1)) / 2)*(((MAX)*(MAX + 1)) / 2))); printf("Sum of squares: %d\n", ((MAX*(MAX + 1)*(2 * MAX + 1)) / 6)); printf("Answer: %d\n", ((((MAX)*(MAX + 1)) / 2)*(((MAX)*(MAX + 1)) / 2)) - ((MAX*(MAX + 1)*(2 * MAX + 1)) / 6)); return 0;} Colored by Color S.. 매개변수 1. CBV VS CBR 함수 호출 방식에는 CBV(Call-By-Value)와 CBR(Call-By-Reference)의 두 가지가 있다. 전자는 값에 의한 호출, 즉 값을 함수로 전달하는 방식이고 후자는 참조에 의한 호출, 즉 메모리 접근을 위한 주소값을 전달하는 방식이다. 따라서 앞에서 정의한 함수들은 모두 CBV 방식이라고 할 수 있다. 그런데 왜 이 둘을 구분하는 걸까? 다음과 같이 두 수의 값을 바꾸는 swap 함수를 정의한다고 해보자. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #include void swap(int a, int b); int main() { int num1= 3, num2 = 5; printf("n.. 프로그램의 작동 환경 1. OS와 하드웨어가 프로그램의 작동 환경을 결정한다. LOL(League Of Legends)의 작동 환경(시스템의 요구 사항)은 다음과 같다. OS Windows XP SP3 이상, Windows Vista, Windows 7, Windows 8 또는 Windows 10 정품 CPU CPU 3GHz 램 4GB 하드 12GB 그래픽 GeForce 8800 또는 동급 그래픽 카드 이상(512MB 이상 비디오 메모리, 전용 GPU가 적용된) 여러가지 OS를 설치할 수 있는 하드웨어도 있고 여러 종류의 하드웨어에서 작동하는 OS도 있다.때문에 소프트웨어의 작동 환경에는 OS와 하드웨어가 모두 명시되어 있어야 한다.윈도우처럼 OS에 여러가지 버전이 있을 경우 특정 버전의 OS를 요구하는 경우도 있다. 프로그.. [Project Euler] Problem 005 사실 그냥 눈으로만 봐도 계산기 켜서 2⁴ × 3² × 5 × 7 × 11 × 13 × 17 × 19를 계산하면 된다는 것을 알 수 있다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 public class Problem005 { public static void main(String[] args) { int dividend = 1; for(int i = 3; i [BAEKJOON] 11721번 12345678910public static void main(String[] args) { Scanner sc = new Scanner(System.in); String input = sc.nextLine(); int i; for(i = 0; i [Project Euler] Problem 004 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465public class Problem004 { public static void main(String[] args) { int num; boolean s1 = false, s2 = false, s3 = false; boolean f1 = false, f2 = false; int max = 0; for(int i = 100; i max) { max = num; } } } else { // num max) { max = num; } } } } } System.out.printf("The larg.. [Project Euler] Problem 003 예전에 Java로 풀었던 문제다. 123456789101112131415161718192021222324252627282930313233343536public class Problem003 { public static void main(String[] args) { long num = 600851475143L; int[] primeFactors = new int[100]; int idx = 0; int i = 2; while((num / i != 1) || (num%i != 0)) { if(num%i == 0) { primeFactors[idx++] = i; num /= i; } else { i++; } if () { primeFactors[idx] = i; break; } } primeFactors[i.. Prev 1 ··· 10 11 12 13 14 15 16 17 Next