ㅅㅂ 처음에는 자바로만 풀었는데 c++를 하니깐 다 까먹었다.

 

기본

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
import java.io.*;
import java.math.*;
 
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        
 
        for(int i = 0 ; i < n ; i++)
        {
            String[] str = bf.readLine().split(" ");
            int x = Integer.parseInt(str[1]);
            int y = Integer.parseInt(str[0]);
        }
 
        int[][] map = new int[x][y];
 
        gogo(map)
        ArrayList<Point> al = new ArrayList<Point>();
        al.add(new Point(x,y))
        al.get(al.size()-1).x;
    }
 
    static class Point
    {
         int x,y;
        Point(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }
 
    static void gogo(int[][] map)
    {
        for(int i = 0 ; i < x ; i++)
    }
}
cs

 

자료구조

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.*;
import java.io.*;
import java.math.*;
 
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        
        ArrayList<Point>[] arr = new ArrayList[n];
 
        for(int i = 0 ; i < n ; i++)
        {
            arr[i] = new ArrayList<Point>();
        }
        
        Queue<int> q = new LinkedList<int>();   // 큐 쓰기
 
        Set<String> s = new HashSet<String>();
 
        Iterator<String> it = set.iterator();
        while(it.hasNext())
        {
            sysout(it.next());
        }
 
}
cs

 

 

 

정렬

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main;
 
import java.util.*;
 
public class test {
 
    public static void main(String[] args) {
        
        
        ArrayList<Integer> arr2 = new ArrayList<Integer>(Arrays.asList(1,2,3,4,5,6,7,8,9));
        
        Collections.sort(arr2, new Comparator<Integer>() // arr은 안된다.
                {
 
                    @Override
                    public int compare(Integer a, Integer b) 
                    {
                        if(a < b)
                            return 1;
                        else
                            return -1;
                    }
                    
                });
        
        for(int i = 0 ; i <arr2.size() ; i++)
        {
            System.out.println(arr2.get(i) + " ");
        }
        
        
        Integer arr[] = new Integer[] {1,2,3,4,5,6,7,8,9}; // 주의점 int형 배열은 안된다!!!!!!
        Arrays.sort(arr, new Comparator<Integer>() {
            public int compare(Integer a, Integer b)
            {
                if(a < b)
                    return 1;
                else
                    return -1;
            }
        });
 
    }
 
}
cs

+ Recent posts