Study/데일리 알고리즘

[BOJ/백준] 단계 1 : 입출력과 사칙연산 - JAVA[자바] 2020. 07. 16

문제 단계 1. 입출력과 사칙연산

문제 번호 10171 - 고양이

문제 번호 10172 - 개

문제 번호 1000 - A+B

문제 번호 1001 - A-B

문제 번호 10998 - A*B

문제 번호 1008 - A/B

문제 번호 10869 - 사칙연산

문제 번호 10430 - 나머지

사용 언어 : JAVA

1단계의 마지막 문제인 곱셈만 빼고 나머지를 모두 풀었다.

학원 커리큘럼을 따라가고 팀 프로젝트가 다가오면서 알고리즘이나 단계별 문제 풀기에 시간이 좀 부족하다.. ㅠ

손 코딩으로 하나하나 직접 해보면서 하고 싶은데 강사님 말대로 선택과 집중을 확실히 정해야 할 것 같다.

그래도 틈틈이 시간이 날 때마다 할 생각이다.(파이팅 미래의 나)

해당 문제들은 어려운 점은 하나도 없었고 단지 고양이 문제를 처음 풀 때

자음+한자로 나오는 특수문자를 사용하지 않고 풀어야 한다는 점을 몰라서 틀렸고

그 뒤로는 모두 Scanner 객체를 사용해 직접 입력을 받아 짜인 수식에 값을 대입해 답이 나오도록 풀었다.

p.s. 블로그에 소스코드 쓸 수 있는 칸을 설정하는 법을 글을 거의 다 작성하고서 알았다 ㅋㅋㅋㅋ

다음부턴 활용해 볼 생각

 

 

고양이

public class Main {


public static void main(String[] args) {


System.out.println("\\ /\\");

System.out.println(" ) ( ')");

System.out.println("( / )");

System.out.println(" \\(__)|");

	}
}

 

public class Main {


public static void main(String[] args) {


System.out.println("|\\_/|");

System.out.println("|q p| /}");

System.out.println("( 0 )\"\"\"\\");

System.out.println("|\"^\"` |");

System.out.println("||_/=\\\\__|");

	}
}

 

A+B

import java.util.Scanner;


public class Main {


public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int A = sc.nextInt();

int B = sc.nextInt();

System.out.println(A+B);

	}
}

 

A-B

import java.util.Scanner;


public class Main {


public static void main(String[] args) {

@SuppressWarnings("resource")

Scanner sc = new Scanner(System.in);

int A = sc.nextInt();

int B = sc.nextInt();

System.out.println(A-B);

	}
}

 

A*B

import java.util.Scanner;


public class Main {


public static void main(String[] args) {

@SuppressWarnings("resource")

Scanner sc = new Scanner(System.in);

int A = sc.nextInt();

int B = sc.nextInt();

System.out.println(A*B);

	}
}

 

A/B

import java.util.Scanner;


public class Main {


public static void main(String[] args) {

@SuppressWarnings("resource")

Scanner sc = new Scanner(System.in);

double A = (double) sc.nextInt();

double B = (double) sc.nextInt();

System.out.println(A/B);

	}
}

 

사칙연산

import java.util.Scanner;


public class Main {


public static void main(String[] args) {

@SuppressWarnings("resource")

Scanner sc = new Scanner(System.in);

int A = sc.nextInt();

int B = sc.nextInt();

System.out.println(A+B);

System.out.println(A-B);

System.out.println(A*B);

System.out.println(A/B);

System.out.println(A%B);

	}
}

 

나머지

import java.util.Scanner;


public class Main {


public static void main(String[] args) {

@SuppressWarnings("resource")

Scanner sc = new Scanner(System.in);

int A = sc.nextInt();

int B = sc.nextInt();

int C = sc.nextInt();

System.out.println((A+B)%C);

System.out.println(((A%C) + (B%C))%C);

System.out.println((A*B)%C);

System.out.println(((A%C)*(B%C))%C);

	}
}