Advertisement
TawratNibir

Untitled

Dec 31st, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5.     char a[] = "aabcccccaaa";
  6.     int count = 1;
  7.     for (int i = 0; a[i] != '\0'; i++)
  8.     {
  9.         for (int j = i + 1; a[j] != '\0'; j++)
  10.         {
  11.             if (a[j] == a[i])
  12.             {
  13.                 count++;
  14.             }
  15.             else
  16.             {
  17.                 break;
  18.             }
  19.         }
  20.         printf("%c%d", a[i], count);
  21.         i += (count - 1);
  22.         count = 1;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement