남영운 :: 남영운

'전체 글'에 해당되는 글 91건

  1. 2019.10.17 C# 백준 2953 나는 요리사다(19.10.17)
  2. 2019.10.17 C# 백준 4344문제 평균은 넘겠지(19.10.17)
  3. 2019.10.17 c# 백준 3052 나머지 구하기(19.10.17)
  4. 2019.10.15 c# 백준 1546번 문제(19.10.15)
  5. 2019.10.15 곱해서 나온 수의 숫자 갯수 구하기(19.10.15)
  6. 2019.10.14 UI 해보기(2019.10.14)
  7. 2019.10.11 OX 퀴즈(19.10.11)
  8. 2019.10.10 배열말고 리스트를 쓰기(19.10.10)

C# 백준 2953 나는 요리사다(19.10.17)

Console(콘솔)/알고리즘 2019. 10. 17. 18:13

https://www.acmicpc.net/problem/2953

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
using System;
 
namespace Syntax
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = new int[5];
            int a = 0;
            for (int i = 0; i < 5; i++)
            {
                int sum = 0;
                string[] str = Console.ReadLine().Split(' ');
                int[] input = new int[str.Length];
                for (int j = 0; j < input.Length; j++)
                {
                    input[j] = int.Parse(str[j]);
                    sum = sum + input[j];
                }
                arr[i] = sum;
            }
            for (int i = 0; i < arr.Length; i++)
            {
                if(arr[a] < arr[i])
                {
                    a = i;
                }
            }
            Console.WriteLine($"{a+1} {arr[a]}");
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

:

C# 백준 4344문제 평균은 넘겠지(19.10.17)

Console(콘솔)/알고리즘 2019. 10. 17. 15:26

https://www.acmicpc.net/problem/4344

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
using System;
 
namespace Syntax
{
    class Program
    {
        static void Main(string[] args)
        {
            int C = int.Parse(Console.ReadLine());
            int sum = 0;
            string[] arr1 = new string[C];
            for (int i = 0; i < C; i++)
            {
                int count = 0;
                sum = 0;
                string[] str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                int[] arr = new int[a];
                for (int j = 0; j < a; j++)
                {
                    arr[j] = int.Parse(str[j+1]);
                    sum = sum + arr[j];
                }
                sum = sum / a;
                for (int k = 0; k < arr.Length; k++)
                {
                    if(arr[k]> sum)
                    {
                        count++;
                    }
                }
                arr1[i] = string.Format("{0:0.000}"Math.Round((double)count / a * 100,3));
            }
            for(int i = 0; i < arr1.Length; i++)
            {
                Console.WriteLine($"{arr1[i]}%");
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

:

c# 백준 3052 나머지 구하기(19.10.17)

Console(콘솔)/알고리즘 2019. 10. 17. 08:23

 

https://www.acmicpc.net/problem/3052

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
using System;
 
namespace Syntax
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A = new int[10];
            int B = 42;
            int amount = 0;
            for (int i = 0; i < A.Length; i++)
            {
                A[i] = int.Parse(Console.ReadLine()) % B;
            }
 
 
            for(int i = 0;i<A.Length;i++)
            {
                for(int j = 0;j<A.Length;j++)
                {
                    if(A[i]==A[j]&&i!=j)
                    {
                        A[j] = 100;
                        break;
                    }
                }
            }
            for(int i = 0;i<A.Length;i++)
            {
                if (A[i] != 100)
                {
                    amount++;
                }
            }
            Console.WriteLine(amount);
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

:

c# 백준 1546번 문제(19.10.15)

Console(콘솔)/알고리즘 2019. 10. 15. 17:56

https://www.acmicpc.net/problem/1546

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
using System;
 
namespace Syntax
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] arr1 = new int[N];
            string str = Console.ReadLine();
            string[] arr2 = str.Split(' ');
            int max = 0;
            int sum = 0;
            for (int i = 0; i < arr2.Length; i++)
            {
                arr1[i] = int.Parse(arr2[i]);
            }
            for (int j = 0; j < arr1.Length; j++)
            {
                sum = sum + arr1[j];
                if (max < arr1[j])
                {
                    max = arr1[j];
                }
            }
            Console.WriteLine(((float)sum / (float)max) * 100 / N);
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

:

곱해서 나온 수의 숫자 갯수 구하기(19.10.15)

Console(콘솔)/알고리즘 2019. 10. 15. 08:45

 

 

:

UI 해보기(2019.10.14)

Console(콘솔)/실습 2019. 10. 14. 15:31

 

:

OX 퀴즈(19.10.11)

Console(콘솔)/알고리즘 2019. 10. 11. 14:58
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
using System;
 
namespace Syntax
{
    class Program
    {
        static void Main(string[] args)
        {
            var length = int.Parse(Console.ReadLine());
            string[] arr = new string[length];
            int j = 0;
            int sum = 0;
            for (int i = 0; i < length; i++)
            {
                arr[i] = Console.ReadLine();
                char[] ch = arr[i].ToCharArray();
                for (int k = 0; k < arr[i].Length; k++)
                {
                    if (ch[k] == 'O')
                    {
                        j = j + 1;
                        sum = sum + j;
 
                    }
                    else
                    {
                        j = 0;
                    }
                }
                Console.WriteLine(sum);
                sum = 0;
                j = 0;
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

:

배열말고 리스트를 쓰기(19.10.10)

Console(콘솔)/실습 2019. 10. 10. 17:00
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
using System;
using System.Collections.Generic;
 
namespace Syntax57
{
    public class App
    {
        public App()
        {
           var inventory= new Inventory();
 
            var item1 = new Item("돌멩이");
            var item2 = new Item("짱돌");
            var item3 = new Item("강돌");
 
            inventory.itemList.Add(item1);
            inventory.itemList.Add(item2);
            inventory.itemList.Add(item3);
 
            inventory.DisplayListItems();
            Console.WriteLine();
            inventory.FindItemByName("짱돌");
            inventory.RemoveItemByName("짱돌");
            Console.WriteLine();
            inventory.DisplayListItems();
 
            Console.WriteLine();
            inventory.GetIndexOfItemByName("강돌");
            Console.WriteLine();
            inventory.GetCount();
        }
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax57
{
    public class Inventory
    {
 
        public List<Item> itemList;
        public Inventory()
        {
            itemList = new List<Item>();
        }
        public void AddItem(Item item)
        {
            itemList.Add(item);
        }
 
        public Item FindItemByName(string item)
        {
            for(int i = 0; i < itemList.Count; i++)
            {
                if (itemList[i].name == item)
                {
                    Console.WriteLine($"{itemList[i].name}을 찾았습니다.");
                    return itemList[i];
                }
            }
            return null;
        }
        public int GetIndexOfItemByName(string name)
        {
            for(int i = 0; i < itemList.Count; i++)
            {
                if(itemList[i].name ==name)
                {
                    Console.WriteLine($"{i}번째 입니다.");
                }
            }
            return -1;
        }
        public void RemoveItemByName(string item)
        {
            for(int i = 0; i < itemList.Count; i++)
            {
                if(itemList[i].name == item)
                {
                    Console.WriteLine($"{itemList[i].name} 제거하셧습니다.");
                    itemList.Remove(itemList[i]);
                    break;
                }
            }
            return;
        }
        public void DisplayListItems()
        {
            Console.WriteLine("리스트");
            for(int i = 0;i<itemList.Count;i++)
            {
                Console.WriteLine(itemList[i].name);
            }
        }
        public int GetCount()
        {
            Console.WriteLine($"{itemList.Count}개 있습니다.");
            return itemList.Count;
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax57
{
    public class Item
    {
        public string name;
        public Item(string name)
        {
            this.name = name;
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

: