Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <mem.h>
- #include <stdbool.h>
- void main()
- {
- char str[100], c, arr[2][100];
- unsigned int length = 0, amount = 0, i, j;
- bool found;
- puts("Enter your string:");
- gets(str);
- length = strlen(str);
- for (i = 0; i < length; i++)
- {
- c = str[i];
- j = 0;
- found = false;
- while ((j < amount + 1) && !(found))
- {
- if ((arr[0][j] != c) && (j == amount))
- {
- arr[0][j] = c;
- arr[1][j] = 1;
- amount++;
- found = true;
- }
- else
- {
- if (arr[0][j] == c)
- {
- (arr[1][j])++;
- found = true;
- }
- }
- j++;
- }
- }
- for (i = 0; i < amount; i++)
- {
- printf("%c%d ", arr[0][i], (int)arr[1][i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement