Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char a[] = "aabcccccaaa";
- int count = 1;
- for (int i = 0; a[i] != '\0'; i++)
- {
- for (int j = i + 1; a[j] != '\0'; j++)
- {
- if (a[j] == a[i])
- {
- count++;
- }
- else
- {
- break;
- }
- }
- printf("%c%d", a[i], count);
- i += (count - 1);
- count = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement