Skip to content

Instantly share code, notes, and snippets.

@dalcon10028
Created July 14, 2020 01:15
Show Gist options
  • Save dalcon10028/a6457cf750cd42980ff882ac029b7a26 to your computer and use it in GitHub Desktop.
Save dalcon10028/a6457cf750cd42980ff882ac029b7a26 to your computer and use it in GitHub Desktop.
4주차 소스코드
// 10809번 알바펫 찾기
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
for (char i = 'a'; i<='z' ; i++)
System.out.print(str.indexOf(i) + " ");
}
}
// 11720번 숫자의 합
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
sc.nextInt(); // 필요없는 입력
String[] input = sc.next().split("");
int[] num = Arrays.stream(input).mapToInt(Integer::parseInt).toArray();
System.out.print(Arrays.stream(num).sum());
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 0;
sc.nextInt(); // 필요없음
String[] str = sc.next().split("");
for (String s : str) sum += Integer.parseInt(s);
System.out.print(sum);
}
}
// 2750번 수 정렬하기
import java.util.*;
class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int[] num = new int[sc.nextInt()];
for(int i=0; i<num.length; i++) num[i] = sc.nextInt();
Arrays.stream(num).sorted().forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment