C# 알고리즘 코딩(프로그래머스)(36)
-
프로그래머스 C# 대소문자 바꿔서 출력하기
using System; using System.Linq; public class Example { public static void Main() { String s; String res = ""; Console.Clear(); s = Console.ReadLine(); for(int i = 0;i
2023.05.25 -
프로그래머스 C# 문자열 반복해서 출력하기
using System; public class Example { public static void Main() { String[] input; Console.Clear(); input = Console.ReadLine().Split(' '); String s1 = input[0]; int a = Int32.Parse(input[1]); for(int i = 0;i
2023.05.24 -
프로그래머스 C# a와 b 출력하기
using System; public class Example { public static void Main() { String[] s; Console.Clear(); s = Console.ReadLine().Split(' '); int a = Int32.Parse(s[0]); int b = Int32.Parse(s[1]); Console.WriteLine("{0}","a = " + a); Console.WriteLine("{0}","b = " + b); } }
2023.05.23 -
프로그래머스 C# 덧셈식 출력하기
using System; public class Example { public static void Main() { String[] s; Console.Clear(); s = Console.ReadLine().Split(' '); int a = Int32.Parse(s[0]); int b = Int32.Parse(s[1]); int c = a + b; Console.WriteLine("{0}", a + " + " + b + " = " + c); } }
2023.05.21 -
프로그래머스 C# 피자 나눠먹기 (1) (파이썬, 자바)
using System; public class Solution { public int solution(int n) { return (int)Math.Ceiling((double)n / 7); } } /// using System; public class Solution { public int solution(int n) { int answer = n / 7 + (n % 7 == 0 ? 0 : 1); /* int answer = n/7; if(n%7 != 0 ) { answer += 1; 나머지가 0이면 그대로가고, 0이 아니면 1을 더해준다. }*/ return answer; } } 파이썬 /// def solution(n): return (n - 1) // 7 + 1 자바 class Solution ..
2023.04.18 -
프로그래머스 C# 과일장수(자바)
using System; using System.Linq; public class Solution { public int solution(int k, int m, int[] score) { int answer = 0; int index = m-1; // m개씩 나누는데 배열은 0부터 시작하니까 -1해줌. Array.Sort(score); // 숫자 크기 순서대로 정렬한 뒤에 Array.Reverse(score); // 배열을 뒤집어서 가장 높은 숫자가 각 박스의 맨 앞에 오도록 해서 for(int i = 0; i = m; i -= m) { answer += score[i - m] * m; } return answer; } }
2023.04.17