Notice
Recent Posts
Recent Comments
Link
250x250
콩부방
[Code up/코드업]C언어 기초 문제100제 자바로 풀기 java 1041~1060 본문
728x90
1041 : [기초-산술연산] 문자 1개 입력받아 다음 문자 출력하기
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.next();
char b = a.charAt(0); // 입력값 b에 대입
b += 1;//아스키 코드값 1증가
System.out.println(b); //char형으로 출력
}
}
1042 : [기초-산술연산] 정수 2개 입력받아 나눈 몫 출력하기
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);
}
}
1043 : [기초-산술연산] 정수 2개 입력받아 나눈 나머지 출력하기
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);
}
}
1044 : [기초-산술연산] 정수 1개 입력받아 1 더해 출력하기
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
System.out.println(++a);
}
}
1045 : [기초-산술연산] 정수 2개 입력받아 자동 계산하기
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);
System.out.println(a - b);
System.out.println(a * b);
System.out.println(a / b);
System.out.println(a % b);
System.out.printf("%.2f",(float)a / b);
}
}
1046 : [기초-산술연산] 정수 3개 입력받아 합과 평균 출력하기
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();
int c = sc.nextInt();
System.out.println(a + b + c);
System.out.printf("%.1f",(a + b + c) / 3.0);
}
}
1047 : [기초-비트시프트연산] 정수 1개 입력받아 2배 곱해 출력하기
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a =sc.nextInt();
System.out.println(a << 1);
}
}
1048 : [기초-비트시프트연산] 한 번에 2의 거듭제곱 배로 출력하기
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();
int c = a << b;
System.out.println(c);
}
}
); } }
1049 : [기초-비교연산] 두 정수 입력받아 비교하기1
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 ? 1 : 0 );
}
}
1050 : [기초-비교연산] 두 정수 입력받아 비교하기2
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 ? 1 : 0 );
}
}
1051 : [기초-비교연산] 두 정수 입력받아 비교하기3
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 ? 1 : 0 );
}
}
); } }
1052 : [기초-비교연산] 두 정수 입력받아 비교하기4
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 ? 1 : 0 );
}
}
1053 : [기초-논리연산] 참 거짓 바꾸기
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a =sc.nextInt();
System.out.println(a == 0 ? 1 : 0);
}
}
1054 : [기초-논리연산] 둘 다 참일 경우만 참 출력하기
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); //비트연산으로도 가능
}
}
1055 : [기초-논리연산] 하나라도 참이면 참 출력하기
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); //비트연산으로도 가능
}
}
1056 : [기초-논리연산] 참/거짓이 서로 다를 때에만 참 출력하기
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);
}
}
1057 : [기초-논리연산] 참/거짓이 서로 같을 때에만 참 출력하기
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 ? 1 : 0);
}
}
1058 : [기초-논리연산] 둘 다 거짓일 경우만 참 출력하기
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(); // not and
if(a == 0 && b == 0) System.out.println(1);
else System.out.println(0);
}
}
1059 : [기초-비트단위논리연산] 비트단위로 NOT 하여 출력하기
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a =sc.nextInt();
System.out.println(~a);
}
}
1060 : [기초-비트단위논리연산] 비트단위로 AND 하여 출력하기
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);
}
}
728x90
'알고리즘 공부 > CodeUp기초100제' 카테고리의 다른 글
1002 : [기초-출력] 출력하기02(설명) (0) | 2021.07.30 |
---|---|
1001 : [기초-출력] 출력하기01 (0) | 2021.07.30 |
[Code up/코드업]C언어 기초 문제100제 자바로 풀기 java 1061~1080 (0) | 2021.07.26 |
[Code up/코드업]C언어 기초 문제100제 자바로 풀기 java 1021~1040 (0) | 2021.07.26 |
[Code up/코드업]C언어 기초 문제100제 자바로 풀기 java 1001~1020 (0) | 2021.07.26 |
Comments