본문 바로가기
728x90

전체 글239

[BOJ C#] 10250 ACM 호텔 using System; using System.Text; using System.IO; namespace _10250 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); StringBuilder sb = new StringBuilder(); int data = int.Parse(sr.ReadLine()); while (data > 0) { string[] arr = sr.ReadLine().Split(' '); int h = int.Parse(arr[0].. 2023. 1. 25.
[BOJ C#] 2798 블랙잭 using System; using System.Collections.Generic; using System.Linq; using System.IO; namespace _2798 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); string[] nm = sr.ReadLine().Split(' '); int n = int.Parse(nm[0]); int m = int.Parse(nm[1]); string[] cardString = sr.ReadLine()... 2023. 1. 25.
[BOJ C#] 2775 부녀회장이 될테야 using System; using System.Text; using System.IO; namespace _2775 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); StringBuilder sb = new StringBuilder(); int t = int.Parse(sr.ReadLine()); for(int i = 0; i < t; i++) { int k = int.Parse(sr.ReadLine()); int n = int.Parse(sr.Read.. 2023. 1. 25.
[BOJ C#]11659 구간 합 구하기 4 using System; namespace _11659 { class Program { static void Main(string[] args) { int[] arr = { 0, 5, 4, 3, 2, 1 }; int[] sumarr = new int[5 + 1]; // 합배열 만들기 // sumarr[i] = sumarr[i-1] + arr[i] sumarr[0] = arr[0]; for (int i = 1; i < arr.Length; i++) { sumarr[i] = sumarr[i - 1] + arr[i]; } for (int i = 0; i < 6; i++) { Console.Write("{0,2} ", arr[i]); } Console.WriteLine(); for (int i = 0; i < .. 2023. 1. 16.
[BOJ C#] 11720 숫자의 합 using System; namespace _11720 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string strnum = Console.ReadLine(); string str; int sum = 0; for (int i = 0; i < N; i++) { str = strnum[i].ToString(); sum += int.Parse(str); } Console.WriteLine(sum); } } } 2023. 1. 15.
[BOJ C#] 10988 팰린드롬 using System; using System.Linq; namespace _10988 { class Program { static void Main(string[] args) { string str = Console.ReadLine(); string strReverse = new string(str.Reverse().ToArray()); int palindrome = (str == strReverse) ? 1 : 0; Console.WriteLine(palindrome); } } } 2023. 1. 15.
[ C# 11일차 ] 변하지 않는 데이터 만들기 연습2 1. 배열 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using System.IO; namespace Quest { class App { //생성자 public App() { string json0 = File.ReadAllText("./mission_data.json"); string json1 = File.ReadAllText("./item_data.json"); MissonData[] missonDatas = JsonConvert.DeserializeObject(json0); ItemData[] .. 2023. 1. 13.
[ C# 11일차 ] 변하지 않는 데이터 만들기 연습1 1. 배열 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using System.IO; namespace Cookierun { class App { //생성자 public App() { Console.WriteLine("App"); string json = File.ReadAllText("./item_data.json"); ItemData[] itemDatas = JsonConvert.DeserializeObject(json); foreach(ItemData data in itemDatas) { Conso.. 2023. 1. 13.
[ C# 11일차 ] JSON 직렬화/역직렬화 연습 //직렬화 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using System.IO; namespace Study12 { class App { //생성자 public App() { Console.WriteLine("App"); //직렬화 //동적 배열(리스트) 생성 List items = new List(); //아이템 생성하고 배열에 추가 items.Add(new Item("아대", 5)); items.Add(new Item("창", 11)); items.Add(new Item("너클", 5)); it.. 2023. 1. 13.
[ C# 10일차 ] 배열 직렬화/역직렬화 연습 1. 리스트 + 이니셜라이져 //직렬화 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using Newtonsoft.Json; namespace Day10 { class App { //생성자 public App() { List items = new List(); items.Add(new Item() { Name = "아대", Damage = 6 }); items.Add(new Item() { Name = "완드", Damage = 2 }); items.Add(new Item() { Name = "고양이", Damag.. 2023. 1. 13.
[ C# 10일차 ] 객체1 직렬화/역직렬화 연습 1. 프로퍼티 + 인스턴스 이니셜라이져 //직렬화 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using Newtonsoft.Json; namespace Day10 { class App { //생성자 public App() { Item item = new Item() { Name = "아대", Damage = 6 }; string json = JsonConvert.SerializeObject(item); Console.WriteLine(json); File.WriteAllText("./my_item.json", j.. 2023. 1. 13.
[ C# 10일차 ] 파일 입출력 File.WriteAllText(String, String), File.ReadAllText(String) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace Study11 { class App { //생성자 public App() { File.WriteAllText("./WriteAllText.txt", "새 파일을 만들고 이 문자열을 파일에 쓴 다음 파일을 닫는다!"); } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Syste.. 2023. 1. 13.
728x90