목록전체 글 (113)
W 개발 일지
포인터에 대한 간단한 요약으로는 다음 사진과 같다. 그림과 같이 포인터는 변수의 메모리 주소'만' 가리키는 화살표와 같다. 이를 이용해서 swap 함수를 만들어보자. 두 수를 a, b에 입력받고 출력한 뒤, 이 두 수를 서로 바꿔주는 swap 함수를 만들어 바뀐 수 또한 출력할 예정이다. 완성 코드는 다음과 같다. #include void swap(int* a, int* b); int main() { int a, b = 0; scanf("%d %d", &a, &b); printf("스왑하기 전 : %d %d\n", a, b); swap(&a, &b); printf("스왑한 후 : %d %d\n", a, b); return 0; } void swap(int* a, int* b) { int tmp =*a; ..
Properties and actions Classes and instances are two important object-oriented programming concepts. In fact, "instance" is another name for an object and a "class" is a blueprint of an instance An instance has a properties and actions and we define them in a class. Creating instances we create an instance from a class as follow : new ClassName( ); ex ) class Main { public static void main(Strin..
Using methods : a method is a section of code to which we assign a specific task. ex ) class Main { public static void main(String[] args) { hello(); //Hello method is called } public static void hello() { System.out.println("Hello World"); } } Colored by Color Scripter cs If you define a method outside of a class, there will be an error. To call a method, just write methodName( ) An argument is..
Boolean can only be either true or false. Do not use double quotes. && = and, || = or Control flow class Main { public static void main(String[] args) { System.out.println("Hello Java"); if(condition) { //Run this code; } else if (condition) { //Run this code; } else { //Run this code; } } } Colored by Color Scripter cs Switch statements. class Main { public static void main(String[] args) { Sys..
progate.com/dashboard Progate | Learn to code, learn to be creative. Progate is an online platform to learn programming. Learn to build your own apps and services. progate.com 프로게이트에서 자바 강의를 듣고 있다. 이론과 예시를 간단하게 슬라이드로 보여준 후, 바로 직접 코드를 짤 수 있는 예제가 주어져서 부담없이 공부하기 쉽다. 총 6개의 단계로 나눠져 있으며 내 기억으로는 3단계 이후부터는 멤버십을 가입해야 볼 수 있었다. 프로게이트 플러스 멤버십은 달에 $9.99 정도. 자바 외에도 다른 언어가 많아서 조금 더 들어볼 것 같다. 영어로 설명하긴 하지만 굳이 사전..
class Solution: def solution(self, n1, n2, K): self.n1 = n1 self.n2 = n2 self.K = K self.t=[] if self.n2>=1 and self.n1>=1: for i in range(self.n1+self.n2): self.t.append('M') d=self.K i=0 r=[] while True: if d>len(self.t): while True: d = d-len(self.t) if d
from math import * class Solution: def solution(self, x, y1, y2): self.a = x self.b = y1 self.c = y2 sum=0 for i in range(len(self.a)): if(self.b[i]>self.c[i]): arg1 = self.b[i] arg2 = self.c[i] else : arg1 = self.c[i] arg2 = self.b[i] res = atan2(arg1,self.a[i])/pi res -= atan2(arg2,self.a[i])/pi sum += res return sum cs 이 문제를 풀기 위해서는 atan2 함수와 라디안(호도법) 단위를 알아야 한다. 라디안 범위는 원에 반지름에 대한 호의 길이의 비이다..
class Solution: def solution(self, sequence): self.s = sequence self.t = list(set(self.s)) for i in self.t: k = self.s.count(i) for j in range(k-1): self.s.remove(i) return self.s cs set()으로 중복되는 숫자를 제거해 어떤 숫자들이 있는지를 먼저 파악 후, k에 몇 번 중복되는지 갯수를 담는다. remove()는 처음 나오는 자료부터 지우기 때문에 k-1 만큼 중복된 숫자를 지워주면 된다. 출처 : www.oncoder.com/