Notice
Recent Posts
Recent Comments
Link
기린의 기록을 위한 공간
[JAVA]codeUp코드업 기초100제 자바로 풀기(1061~1080) 본문
1061
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();
//비트연산자 or |
System.out.print(a|b);
}
}
1062
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();
//비트연산자 xor ^
System.out.print(a^b);
}
}
1063
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();
System.out.println(a>b?a:b);
}
}
1064
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();
System.out.print("정수입력 : ");
int c = sc.nextInt();
System.out.println((a<b?a:b)<c?(a<b?a:b):c);
}
}
1065
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();
System.out.print("정수입력 : ");
int c = sc.nextInt();
if(a%2==0) {
System.out.println(a);
}
if(b%2==0) {
System.out.println(b);
}
if(c%2==0) {
System.out.println(c);
}
}
}
1066
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();
System.out.print("정수입력 : ");
int c = sc.nextInt();
if(a%2==0) {
System.out.println("even");
}else {
System.out.println("odd");
}
if(b%2==0) {
System.out.println("even");
}else {
System.out.println("odd");
}
if(c%2==0) {
System.out.println("even");
}else {
System.out.println("odd");
}
}
1067
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();
if(a<0) {
System.out.println("minus");
if(a%2==0) {
System.out.println("even");
}
}
}
}
1068
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();
if(a>=90&&a<=100) {
System.out.print("A");
}else if(a>=70&&a<=89) {
System.out.print("B");
}else if(a>=40&&a<=69) {
System.out.print("C");
}else {
System.out.print("D");
}
}
}
1069
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("문자 입력 : ");
char a = sc.next().charAt(0);
switch(a) {
case 'A' : System.out.println("best!!");break;
case 'B' : System.out.println("good!!");break;
case 'C' : System.out.println("run!");break;
case 'D' : System.out.println("slowly~");break;
default : System.out.println("what?");break;
}
}
}
1070
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();
if(a==1||a==2||a==12) {
System.out.println("winter");
}else if(a>=3&&a<=5) {
System.out.println("spring");
}else if(a>=6&&a<=8) {
System.out.println("summer");
}else {
System.out.println("fall");
}
}
}
1071
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true) {
System.out.print("정수 입력 : ");
int a = sc .nextInt();
if(a==0) {
break;
}
System.out.println(a);
}
}
}
1072
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();
//입력받은 a크기만큼의 배열을 만든다
int arr[] = new int[a];
//배열에 값을 누적시킨다.
for(int i=0; i<arr.length; i++) {
arr[i]=+i+1;
}
//출력하는 for문
for(int i=0; i<arr.length; i++) {
System.out.println(arr[i]);
}
}
}
1073
package com.algo.controller;
import java.util.Scanner;
public class Code{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true) {
System.out.print("정수입력 : ");
int a = sc.nextInt();
if(a==0) {
break;
}
System.out.println(a);
}
}
}
1074
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();
if(a>=1&&a<=100) {
for(int i=a; i>0; i--) {
System.out.println(i);
}
}
}
}
1075
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();
if(a>=1&&a<=100) {
for(int i=a; i>0; i--) {
System.out.println(i-1);
}
}
}
}
1076
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("알파벳 입력 : ");
char word = sc.next().charAt(0);
char start = 'a';
do {
System.out.print(start+" ");
start+=1;
}while(start<=word);
}
}
1077
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();
for(int i=0; i<=a; i++) {
System.out.println(i);
}
}
}
1078
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();
int sum=0;
for(int i=1; i<=a; i++) {
if(i%2==0) {
sum+=i;
}
}
System.out.print(sum);
}
}
1079
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("문자입력 : ");
while(true) {
char a = sc.next().charAt(0);
if(a=='q') {
System.out.println(a);break;
}
System.out.println(a);
}
}
}
1080
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();
int sum=0;
int count=0;
if(a>=0&&a<=1000) {
while(sum<a) {
count++;
sum+=count;
}
}
System.out.println(count);
}
}
'Algorithm > codeUp기초100제' 카테고리의 다른 글
[JAVA]codeUp코드업 기초100제 자바로 풀기(1081~1099) (5) | 2020.03.01 |
---|---|
[JAVA]codeUp코드업 기초100제 자바로 풀기(1041~1060) (0) | 2020.02.23 |
[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