https://www.acmicpc.net/problem/2577
2741๋ฒ: N ์ฐ๊ธฐ
์์ฐ์ N์ด ์ฃผ์ด์ก์ ๋, 1๋ถํฐ N๊น์ง ํ ์ค์ ํ๋์ฉ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
www.acmicpc.net
My Solution
- length : ๋ฌธ์์ด์ ๊ธธ์ด๋ฅผ ๊ตฌํ๋ ๋ฉ์๋
- replace : ๊ธฐ์กด์ ๋ฌธ์๋ฅผ ๋์ฒดํ๋ ๋ฉ์๋
- ToString : String ๊ฐ์ผ๋ก ๋ณํํ๋ ๋ฉ์๋
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int c = int.Parse(Console.ReadLine());
string numbers = (a * b * c).ToString();
for (int i = 0; i < 10; i++)
{
~~Console.WriteLine(numbers.Length - numbers.Replace(i.ToString(), "").Length);~~
}
}
}
}
Solution
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int c = int.Parse(Console.ReadLine());
string numbers = (a * b * c).ToString();
for (int i = 0; i < 10; i++)
{
Console.WriteLine(numbers.Length - numbers.Replace(i.ToString(), "").Length);
}
}
}
}
'๐ฉโ๐ปProgramming > Coding Test' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [C#] [BOJ#1546] ๋๋จธ์ง - ํ๊ท (0) | 2022.07.30 |
|---|---|
| [C#] [BOJ#3052] ๋๋จธ์ง - ์ค๋ณต ์ ๊ฑฐ (0) | 2022.07.30 |
| [C#] [BOJ#2562] ์ต๋๊ฐ (0) | 2022.07.30 |
| [C#] [BOJ#10871] X๋ณด๋ค ์์ ์ (0) | 2022.07.30 |
| [C#] [BOJ#11021] A+B - 7 / A+B - 8 (0) | 2022.07.30 |
๋๊ธ