File tree Expand file tree Collapse file tree 10 files changed +185
-0
lines changed
Expand file tree Collapse file tree 10 files changed +185
-0
lines changed Original file line number Diff line number Diff line change 1+ # 2017-09-06 풀이 목록
2+ * 선택 정렬 2[ 코드 보기] ( selectionsort/B.java )
3+ * 소수 구하기 2[ 코드 보기] ( primenumber/B.java )
4+ * 버블 소트 2[ 코드 보기] ( bubblesort/B.java )
5+ # 2017-09-05 풀이 목록
6+ * 버블 소트 1[ 코드 보기] ( bubblesort/A.java )
17# 2017-09-04 풀이 목록
28* 소수 구하기 1[ 코드 보기] ( primenumber/A.java )
39* 선택 정렬 1[ 코드 보기] ( selectionsort/A.java )
Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+ class A {
3+ public static void main (String args []){
4+ Scanner sc = new Scanner (System .in );
5+ int length = Integer .parseInt (sc .nextLine ().trim ());//N
6+
7+ int a []=new int [length ];//N만큼 배열 생성
8+ String s =sc .nextLine ().trim ();//배열
9+ String ss []=s .split (" " );//배열
10+ for (int i =0 ;i <length ;i ++){
11+ a [i ]=Integer .parseInt (ss [i ]);//배열 집어넣기
12+ }
13+ int lengthh =Integer .parseInt (sc .nextLine ().trim ());//K
14+ int aa [];
15+ StringBuilder print =new StringBuilder ();
16+ for (int i =0 ;i <lengthh ;i ++){
17+ aa =a .clone ();
18+ String aaaa []=sc .nextLine ().trim ().split (" " );
19+ int abcd =Integer .parseInt (aaaa [0 ]),efgh =Integer .parseInt (aaaa [1 ]);// A B
20+ for (int j =0 ;j <abcd -1 ;j ++){
21+ for (int k =j +1 ;k <abcd ;k ++){
22+ if (aa [j ]>aa [k ]){
23+ int temp =aa [j ];
24+ aa [j ]=aa [k ];
25+ aa [k ]=temp ;
26+ }
27+ }
28+ }
29+ for (int j =0 ;j <efgh -1 ;j ++){
30+ for (int k =j +1 ;k <efgh ;k ++){
31+ if (aa [j ]<aa [k ]){
32+ int temp =aa [j ];
33+ aa [j ]=aa [k ];
34+ aa [k ]=temp ;
35+ }
36+ }
37+ }
38+ for (int abcdf : aa ){
39+ print .append (abcdf );print .append (" " );
40+ }
41+ print .append ("\n " );
42+ }
43+ System .out .println (print .toString ());
44+ }
45+ }
Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+ import java .io .*;
3+ class B {
4+ public static void main (String args []) throws IOException {
5+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
6+ BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System .out ));
7+ int N = Integer .parseInt (br .readLine ());
8+ int arr []=new int [N ];
9+ for (int i =0 ;i <N ;i ++){
10+ arr [i ]=Integer .parseInt (br .readLine ());
11+ }
12+ Sort (arr );
13+ for (int i =0 ;i <N ;i ++){
14+ bw .write (arr [i ]+"\n " );
15+ }
16+ bw .flush ();
17+ }
18+ private static void Sort (int arr []){
19+ int temp ;
20+ for (int i =0 ;i <arr .length -1 ;i ++){
21+ for (int j =i +1 ;j <arr .length ;j ++){
22+ if (arr [i ]>arr [j ]){
23+ temp =arr [j ];
24+ arr [j ]=arr [i ];
25+ arr [i ]=temp ;
26+ }
27+ }
28+ }
29+ }
30+ // public static void main(String args[]) throws IOException{
31+ // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
32+ // BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
33+ // int N = Integer.parseInt(br.readLine());
34+ // int arr[]=new int[2000001];
35+ // for(int i=0;i<N;i++){
36+ // ++arr[Integer.parseInt(br.readLine())+1000000];
37+ // }
38+ // for(int i=0;i<arr.length;i++){
39+ // if(arr[i]>0)
40+ // bw.write((i-1000000)+"\n");
41+ // }
42+ // bw.flush();
43+ // }
44+ }
Original file line number Diff line number Diff line change 1+ # 버블 소트
2+ 정렬되는 모양이 거품같아서 버블소트
Original file line number Diff line number Diff line change 1+ import java .util .*;
2+ import java .io .*;
3+ class B {
4+ public static void main (String [] args ) throws IOException {
5+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
6+ BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System .out ));
7+ int T = Integer .parseInt (br .readLine ());
8+ LinkedList <Integer > l =new LinkedList <>();
9+ for (int i =2 ;i <996 ;i ++){
10+ boolean a =false ;
11+ double b = Math .sqrt (i );
12+ for (int j =2 ;j <=b ;j ++){
13+ if (i %j ==0 ){
14+ a =true ;
15+ }
16+ }
17+ if (!a ){
18+ l .add (i );
19+ }
20+ }
21+ for (int i =0 ;i <T ;i ++){
22+ boolean a =true ;
23+ int check =Integer .parseInt (br .readLine ());
24+ abcd :
25+ for (int o : l ){
26+ for (int oo :l ){
27+ for (int ooo :l ){
28+ if (o +oo +ooo ==check ){
29+ a =false ;
30+ bw .write (o +" " +oo +" " +ooo );
31+ break abcd ;
32+ }
33+ }
34+ }
35+ }
36+ if (a ){
37+ bw .write ("0" );
38+ }
39+ bw .write ("\n " );
40+ }
41+ bw .flush ();
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+ import java .io .OutputStream ;
3+ import java .io .BufferedOutputStream ;
4+ import java .io .IOException ;
5+ class B {
6+ public static void main (String args []){
7+ Scanner sc =new Scanner (System .in );
8+ int N =sc .nextInt ();
9+ int arr []=new int [N ];
10+ for (int i =0 ;i <N ;i ++){
11+ arr [i ]=Integer .parseInt (sc .nextLine ().trim ());
12+ }
13+ Sort (true ,arr );
14+ for (int i =0 ;i <N ;i ++){
15+ System .out .println (arr [i ]);
16+ }
17+ }
18+ private static void Sort (boolean ASC ,int arr []){
19+ int temp ;
20+ for (int i =0 ;i <arr .length -1 ;i ++){
21+ for (int j =i ;j <arr .length ;j ++){
22+ if (arr [i ]>arr [j ]){
23+ temp =arr [j ];
24+ arr [j ]=arr [i ];
25+ arr [i ]=temp ;
26+ }
27+ }
28+ }
29+ }
30+ // public static void main(String args[]) throws IOException{
31+ // Scanner sc=new Scanner(System.in);
32+ // int N=sc.nextInt();
33+ // int arr[]=new int[10001];
34+ // for(int i=0;i<N;i++){
35+ // arr[sc.nextInt()]++;
36+ // }
37+ // OutputStream os = new BufferedOutputStream(System.out);
38+ // for (int i = 1; i <= 10000; i++) {
39+ // for (int j = 0; j < arr[i]; j++) {
40+ // os.write((i + "\n").getBytes());
41+ // }
42+ // }
43+ // os.flush();
44+ // }
45+ }
You can’t perform that action at this time.
0 commit comments