using System;
namespace Practice_Page
{
class Program
{
static void Main(string[] args)
{
while (true)
{
int[] array = new int[100];
for (int i = 0; i < array.Length; i++)
{
array[i] = Console.Read();
if (array[i] == 13)
break;
}
int count = 0;
int index = 0;
Console.Write(">> ");
for (int i = 0; i < array.Length; i++)
{
if (array[i] == array[index])
{
count++;
}
else
{
Console.Write((char)array[index] + "" + count);
if (array[i] == 13)
{
array[0] = Console.Read(); // [34] ~ [35] 버퍼값 삭제하는 법을 몰라서 대충 때웠다.
array[0] = 0;
Console.WriteLine();
break;
}
else
{
index = i;
i -= 1;
count = 0;
}
}
}
}
}
}
}
입력 받은 수열의 개미 수열을 구하는 코드.
입력 받은 개행문자를 지우는 법을 몰라 땜빵한 부분이 부끄럽다.
'프로그래밍 > 알고리즘' 카테고리의 다른 글
[방학의 PS] 다이나믹 프로그래밍(DP) - BOJ_1463 (0) | 2022.06.15 |
---|---|
[방학의 PS] 균형잡힌 세상 - BOJ_4949 (0) | 2022.06.15 |
[방학의 PS] 프린터 큐 - BOJ_1966 (0) | 2022.06.15 |
[방학의 PS] 이분 탐색과 매개 변수 탐색 - BOJ_2805, BOJ_1654 (0) | 2022.06.15 |
에라토스테네스의 체 (0) | 2022.03.16 |