1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> void printRLE(char str[]) { int n = strlen(str); for (int i = 0; i < n; i++) { int count = 1; while (i < n - 1 && str[i] == str[i + 1]) { count++; i++; } printf("%d%c", count, str[i]); } printf("\n\n"); } int main(void) { char s[100]; printf("¹®ÀÚ¿À» ÀÔ·ÂÇϽÿÀ: "); gets_s(s, 100); printRLE(s); return 0; } | cs |
¸ð¹ü´ä¾È¿¡´Â º¹±¸ÇÏ´Â ÇÁ·Î±×·¥ÀÌ ¾øÀ½
º¹±¸ÇÏ´Â ÇÁ·Î±×·¥Àº Ãß°¡±¸Çö¿¡ ±¸Çö (¾ÏÈ£´Â ¼ö¾÷½Ã°£¿¡ ¾Ë·ÁÁØ ¾ÏÈ£)