charAt(0) 을 통해 입력 받은 값들 char형 변수에 할당한다.


import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
char ch = sc.nextLine().charAt(0);
System.out.println((int)(ch));
}
}
view raw test.java hosted with ❤ by GitHub


빠르게 짰다.


import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int result = 0;
Scanner sc = new Scanner(System.in);
int[] a = new int[5];
for(int i=0; i<5; i++) {
a[i] = sc.nextInt();
if(a[i]<40) {
a[i]=40;
}
result = result+a[i];
}
int b = result/5;
System.out.println(b);
}
}
view raw test.java hosted with ❤ by GitHub

+ Recent posts