1 | 10818 | ์ต์, ์ต๋ |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int T = scan.nextInt();
int a[] = new int[T];
for(int i=0; i<T; i++) {
int b = scan.nextInt();
a[i] = b;
}
int max = a[0];
int min = a[0];
for(int i=1; i<T; i++) {
if( a[i] > max)
max = a[i];
if(a[i] < min)
min = a[i];
}
System.out.print(min + " ");
System.out.print(max);
}
}
2 | 2562 | ์ต๋๊ฐ |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan =new Scanner(System.in);
int T = 9;
int a[] = new int[T];
for(int i=0; i<T; i++) {
a[i] = scan.nextInt();
}
int max = a[0];
int number = 1;
for(int i=0; i<T; i++) {
if(a[i]>max) {
max=a[i];
number = i+1;
}
}
System.out.println(max + " " + number);
scan.close();
}
}
3 | 2577 | ์ซ์์ ๊ฐ์ |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
int number[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
String mix = Integer.toString(a*b*c);
String zz[] = mix.split("");
for(int i=0; i<mix.length(); i++) {
switch (zz[i]) {
case "0" : number[0]+=1; break;
case "1" : number[1]+=1;break;
case "2" : number[2]+=1;break;
case "3" : number[3]+=1;break;
case "4" : number[4]+=1;break;
case "5" : number[5]+=1;break;
case "6" : number[6]+=1;break;
case "7" : number[7]+=1;break;
case "8" : number[8]+=1;break;
case "9" : number[9]+=1; break;
default:
break;
}
}
for(int i=0; i<10; i++)
System.out.println(number[i]);
scan.close();
}
}
4 | 3052 | ๋๋จธ์ง |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int number =10;
int a[] = new int[number];
int b[] = new int[number];
int count = 10;
for(int i= 0; i<number; i++) {
a[i] = scan.nextInt();
b[i] = a[i]%42;
for(int j=0; j<i; j++) {
if(b[i] == b[j]) {
count--;
break;
}
}
}
System.out.println(count);
scan.close();
}
}
5 | 1546 | ํ๊ท |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testCount = scan.nextInt();//์ํ๋ณธ ๊ณผ๋ชฉ ๊ฐ์
double a[] = new double[testCount];
for(int i=0; i<a.length; i++) {
a[i] = scan.nextInt();
}
double M = a[0];
for(int i=1; i<a.length; i++) {
if(M < a[i])
M = a[i];
}
double sum =0;
for(int i=0; i<a.length; i++) {
a[i] = a[i]/M*100;
sum += a[i];
}
System.out.println(sum/testCount);
scan.close();
}
}
6 | 8958 | OXํด์ฆ |
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String a[] = new String [scan.nextInt()];
scan.nextLine();
for(int i=0; i<a.length; i++)
a[i] = scan.nextLine();
for(int i= 0; i<a.length; i++) {
int score = 0;
int sum = 0;
for(int j=0; j<a[i].length(); j++) {
if(a[i].charAt(j) == 'O') {
score++;
sum += score;
}
else score = 0;
}
System.out.println(sum);
}
scan.close();
}
}
7 | 4344 | ํ๊ท ์ ๋๊ฒ ์ง |
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
//BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
int C = scan.nextInt(); //ํ
์คํธ์ผ์ด์ค.
int student[][] = new int[C][]; //ํ์์ ์์ ์ ์.
for(int i=0; i<student.length; i++) {
float sum = 0;
float avg = 0;
float count = 0;
student[i] = new int [scan.nextInt()]; //2์ฐจ์๋ฐฐ์ด ๋์ ํ ๋น //์ฌ๊ธฐ์ ๋ง์ง๋ง ํ
์คํธ์ ๋ง์ง๋ง์ ์ ๋ฃ๊ณ ์ํฐ์๋๋ฅด๋ฉด ์๋์ด๊ฐ์ง
for(int j=0; j<student[i].length; j++) { //ํ ๊ฐ ๊ตฌํ๊ธฐ.
student[i][j] = scan.nextInt();
sum += student[i][j];
}
avg = sum / student[i].length;
for(int z=0; z<student[i].length; z++)
if(student[i][z] > avg) count++;
float percent = (100/(float)student[i].length) * count;
System.out.printf("%.3f", percent);
System.out.println("%");
}
scan.close();
}
}
๋ง์ง๋ง 6๋ฒ๊ณผ 7๋ฒ๋ฌธ์ ๋ ์ฝ๊ณ ๋น ๋ฅด๊ฒ ํ๋ฆฌ์ง ์์๋ ๊ฒ ๊ฐ๋ค.
2์ฐจ์ ๋ฐฐ์ด์์์ ๋์ ํ ๋น๊ณผ, String ๋ฌธ์์์ ๊ฐ ๊ธ์๋ฅผ ๋ฐฐ์ด์ฒ๋ผ ์ชผ๊ฐ์ ํ๋จํ๋ ๊ฒ์ ๋ค์ ์๊ธฐํ๋ค.
์ํฐ๋ฅผ ์์น๋ฉด ๋ง์ง๋ง ์ ๋ ฅ์ด ์๋์ด์, ๋ง์ง๋ง ๋จ๊ณ์ scan.nextInt()์ nextLine์ ํ๋ฒ ํด์ค์ผ๋ก์จ ํ์๋ค.
728x90
๋ฐ์ํ