티스토리 뷰

list<int> 생성해두고 10개의 값을 하나씩 받고 42로 나눈다음, Contain()을 이용해 list에 해당 값이 있는 지 검사한다.

없으면 저장한다.

이후 list.count 출력.


  
            BufferedStream bs = new BufferedStream(Console.OpenStandardInput());
            StreamReader sr = new StreamReader(bs);
            List input = new List();
            int value;

            for(int i = 0; i<10; i++)
            {
                value = int.Parse(sr.ReadLine()) % 42;
                if (!input.Contains(value))
                    input.Add(value);
            }
            Console.WriteLine(input.Count);

'■ 알고리즘 > ◻ 백준' 카테고리의 다른 글

[C#]백준 10808번 : 알파벳 개수  (0) 2018.08.14
[C#]백준 10807번 : 개수 세기  (0) 2018.08.14
[C#]백준 2902번 : KMP?  (0) 2018.08.14
[C#]백준 5430번 : AC  (0) 2018.08.14
[C#/C++]백준 10809번 : 알파벳 찾기  (0) 2018.08.14
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/11   »
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
글 보관함