Notice
Recent Posts
Recent Comments
Link
기린의 기록을 위한 공간
[JAVA]codeUp코드업 기초100제 자바로 풀기(1041~1060) 본문
1041
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
char word = sc.next().charAt(0);
System.out.println((char)(word+1));
}
}
1042
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
StringTokenizer st = new StringTokenizer(nums," ");
String arr[] = new String[2];
int i=0;
while(st.hasMoreTokens()) {
arr[i] = st.nextToken();
i+=1;
}
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
System.out.println(a/b);
}
}
1043
package com.algo.controller;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
StringTokenizer st = new StringTokenizer(nums," ");
String arr[] = new String[2];
int i=0;
while(st.hasMoreTokens()) {
arr[i] = st.nextToken();
i+=1;
}
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
System.out.println(a%b);
}
}
1044
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long num = sc.nextLong();
System.out.println(++num);
}
}
1045
package com.algo.controller;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
String[] arr =nums.split(" ");
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
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);
}
}
1046
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
String arr[] = nums.split(" ");
long sum = 0;
double avg = 0;
for(int i=0; i<arr.length; i++) {
int num = Integer.parseInt(arr[i]);
if(num >= -2147483648 && num <= 2147483647){
sum+=num;
}else {
System.out.println("-2147483648 ~ 2147483647사이의 정수를 입력하세요.");
break;
}
}
avg = (double)sum/3;
System.out.println(sum);
System.out.format("%.1f",avg);
}
}
1047
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
//정수 a의 각 비트를 b만큼 왼쪽으로 이동(빈자리는 0으로 채워진다)
System.out.println(a<<1);
1048
package com.algo.controller;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
StringTokenizer st = new StringTokenizer(nums," ");
String arr[] = new String[2];
int i=0;
while(st.hasMoreTokens()) {
arr[i]=st.nextToken();
i+=1;
}
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
System.out.println(a<<b);
}
}
1049
package com.algo.controller;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
StringTokenizer st = new StringTokenizer(nums," ");
String arr[] = new String[2];
int i=0;
while(st.hasMoreTokens()) {
arr[i]=st.nextToken();
i+=1;
}
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
if(a>b) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1050
package com.algo.controller;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
StringTokenizer st = new StringTokenizer(nums," ");
String arr[] = new String[2];
int i=0;
while(st.hasMoreTokens()) {
arr[i]=st.nextToken();
i+=1;
}
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
if(a==b) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1051
package com.algo.controller;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
StringTokenizer st = new StringTokenizer(nums," ");
String arr[] = new String[2];
int i=0;
while(st.hasMoreTokens()) {
arr[i]=st.nextToken();
i+=1;
}
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
if(a<=b) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1052
package com.algo.controller;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String nums = sc.nextLine();
StringTokenizer st = new StringTokenizer(nums," ");
String arr[] = new String[2];
int i=0;
while(st.hasMoreTokens()) {
arr[i]=st.nextToken();
i+=1;
}
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
if(a!=b) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1053
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
if(num==0||num==1) {
if(num==0) {
System.out.print(1);
}else {
System.out.print(0);
}
}else {
System.out.println("0또는 1만 입력하세요.");
}
1054
package com.algo.controller;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String num = sc.nextLine();
StringTokenizer st = new StringTokenizer(num," ");
String arr[] = new String [2];
int i=0;
while(st.hasMoreTokens()) {
arr[i]=st.nextToken();
i+=1;
}
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
if(a==1&&b==1) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1055
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("정수 입력(1/0) : ");
int a = sc.nextInt();
System.out.print("정수 입력(1/0) : ");
int b = sc.nextInt();
if(a==1||b==1) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1056
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("정수 입력(1/0) : ");
int a = sc.nextInt();
System.out.print("정수 입력(1/0) : ");
int b = sc.nextInt();
if(a!=1&&b==1||a==1&&b!=1) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1057
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("정수 입력(1/0) : ");
int a = sc.nextInt();
System.out.print("정수 입력(1/0) : ");
int b = sc.nextInt();
if(a!=1&&b!=1||a==1&&b==1||a!=0&&b!=0||a==0&&b==0) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1058
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("정수 입력(1/0) : ");
int a = sc.nextInt();
System.out.print("정수 입력(1/0) : ");
int b = sc.nextInt();
if(a==0&&b==0) {
System.out.print(1);
}else {
System.out.print(0);
}
}
}
1059
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
//비트연산자 NOT ~
System.out.println(~num);
}
}
1060
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("정수입력 : ");
int a = sc.nextInt();
System.out.print("정수입력 : ");
int b = sc.nextInt();
//비트연산자 AND &
System.out.print(a&b);
}
}
'Algorithm > codeUp기초100제' 카테고리의 다른 글
[JAVA]codeUp코드업 기초100제 자바로 풀기(1081~1099) (5) | 2020.03.01 |
---|---|
[JAVA]codeUp코드업 기초100제 자바로 풀기(1061~1080) (0) | 2020.02.27 |
[JAVA]codeUp코드업 기초100제 자바로 풀기(1022~1040) (2) | 2020.02.23 |
[JAVA]codeUp코드업 기초100제 자바로 풀기(1015~1021) (0) | 2020.02.21 |
[JAVA]codeUp코드업 기초100제 자바로 풀기(1001~1014) (0) | 2020.02.21 |
Comments