반응형 전체 글552 백준 C# - 10430 using System; namespace baek2 { class Program { static void Main(string[] args) { string word = Console.ReadLine(); string[] token = word.Split(); int A = int.Parse(token[0]); int B = int.Parse(token[1]); int C = int.Parse(token[2]); Console.WriteLine((A + B) % C); Console.WriteLine(((A % C) + (B % C)) % C); Console.WriteLine((A * B) % C); Console.Write(((A % C) * (B % C)) % C); } } } 2023. 10. 31. Unity - GraphicRaycaster(2D), Physics.Raycast(3D) Physics.Raycast 일반적으로 3D 레이캐스팅을 수행한다. Ray를 통해 충돌하는 오브젝트를 찾는다. public static bool Raycast(Vector3 origin, Vector3 direction, float maxDistance = Mathf.Infinity, int layerMask = DefaultRaycastLayers); origin에서 시작하여 direction으로 maxdistance만큼 ray를 쏜다. 이 ray는 현재 Scene에 있는 모든 Collider를 감지하기 위해 사용된다. 또한 선택적으로 LayerMask를 통해 특 정레이어에 속한 Collider만 충돌 검출을 할 수 있다. 간단한 예제 코드 public class PhysicsRaycastExample.. 2023. 10. 31. 백준 C# - 11656 +) 풀이 풀이 01 앞에서부터 하나씩 뺀 다음 배열에 넣기 일단 접미사를 배열에 넣는 순서는 중요하지 않다. 나중에 Sort시켜주기 때문이다. 그러므로 앞에서 하나씩 뺀 다음 배열에 넣어준다. for(int i = 0; i 0) sb.Remove(0, 1); } 02 Sort시켜주기 Array.Sort(list); 03 출력하기 foreach(string s in list) { Console.WriteLine(s); } 코드 전문 using System; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string word = Console.ReadLine(); StringBuilder sb = new St.. 2023. 10. 27. 백준 C# - 10842 +) overflow문제 아래와 같은 코드로 제출을 했는데 계속 overflow에러가 떴다. using System; namespace baek2 { class Program { static void Main(string[] args) { string word = Console.ReadLine(); string[] token = word.Split(); string AB = token[0] + token[1]; string CD = token[2] + token[3]; Console.Write($"{int.Parse(AB) + int.Parse(CD)}"); } } } 문제의 원인 int.Parse 문제에서와 같이 문자열 입력이 1 ≤ A, B, C, D ≤ 1,000,000 이러한 조건이 있다. 문자열을 int.Parse 메서.. 2023. 10. 27. 백준 C# - 11655 +)풀이 풀이 처음에는 isLetter를 사용해서 풀려고 했다. 아스키코드를 사용해서 풀려고 하다보니 대문자와 소문자를 나누어서 풀어야 겠다는 생각이 들었다. 01 소문자 if (Char.IsLower(c)) { num = (int)c + 13; if (num > 122) num -= 26; sb.Append((char)num); continue; } 02 대문자 if(Char.IsUpper(c)) { num = (int)c + 13; if (num > 90) num -= 26; sb.Append((char)num); continue; } 03 그 외 else { sb.Append(c); continue; } 코드 전문 using System; using System.Text; namespace baek2 { c.. 2023. 10. 27. 백준 C# - 2743 딱 떠오른 코드 using System; namespace baek2 { class Program { static void Main(string[] args) { string word = Console.ReadLine(); int num = 0; foreach(char c in word) { num++; } Console.WriteLine(num); } } } 개선한 코드 using System; namespace baek2 { class Program { static void Main(string[] args) { string word = Console.ReadLine(); Console.WriteLine(word.Length); } } } 2023. 10. 27. 이전 1 ··· 41 42 43 44 45 46 47 ··· 92 다음 반응형