본문 바로가기
728x90

알고리즘/백준 BOJ119

[BOJ C#] 1439 뒤집기 중간에 count 확인하려 출력했던 코드를 안지워서 틀렸다..실제로는 이런 실수 안하도록 조심하기!! using System; namespace _1439 { class Program { static void Main() { string str = Console.ReadLine(); int n; int count0 = 0; int count1 = 0; if (str[0] == '0') { n = 0; count0++; } else { n = 1; count1++; } for (int i = 1; i < str.Length; i++) { if (str[i-1] == '0' && str[i] == '1') { n = 1; count1++; } else if (str[i-1] == '1' && str[i] =.. 2023. 1. 28.
[BOJ C#] 5585 거스름돈 using System; namespace _5585 { class Program { static void Main() { int price = int.Parse(Console.ReadLine()); int charge = 1000 - price; int count = 0; while (charge > 0) { if (charge >= 500) { count += (charge / 500); charge %= 500; } else if (charge >= 100) { count += (charge / 100); charge %= 100; } else if (charge >= 50) { count += (charge / 50); charge %= 50; } else if (charge >= 10) { co.. 2023. 1. 27.
[BOJ C#] 1259 팰린드롬수 using System; using System.Linq; using System.Text; using System.IO; namespace _1259 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); StringBuilder sb = new StringBuilder(); while (true) { string str = sr.ReadLine(); if (str == "0") break; string strReverse = new string(str.Re.. 2023. 1. 26.
[BOJ C#] 1085 직사각형에서 탈출 using System; using System.IO; namespace _1085 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); string[] arrString = sr.ReadLine().Split(' '); int x = int.Parse(arrString[0]); int y = int.Parse(arrString[1]); int w = int.Parse(arrString[2]); int h = int.Parse(arrString[3]); in.. 2023. 1. 25.
[BOJ C#] 4153 직각삼각형 using System; using System.Collections.Generic; using System.Text; using System.IO; namespace _4153 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); StringBuilder sb = new StringBuilder(); List arr = new List(); while(true) { string[] arrString = sr.ReadLine().Split(' '); int .. 2023. 1. 25.
[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.
728x90