daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <mem.h>
  3. #include <stdbool.h>
  4.  
  5. void main()
  6. {
  7.     char str[100], c, arr[2][100];
  8.     unsigned int length = 0, amount = 0, i, j;
  9.     bool found;
  10.     puts("Enter your string:");
  11.     gets(str);
  12.     length = strlen(str);
  13.     for (i = 0; i < length; i++)
  14.     {
  15.         c = str[i];
  16.         j = 0;
  17.         found = false;
  18.         while ((j < amount + 1) && !(found))
  19.         {
  20.             if ((arr[0][j] != c) && (j == amount))
  21.             {
  22.                 arr[0][j] = c;
  23.                 arr[1][j] = 1;
  24.                 amount++;
  25.                 found = true;
  26.             }
  27.             else
  28.             {
  29.                 if (arr[0][j] == c)
  30.                 {
  31.                     (arr[1][j])++;
  32.                     found = true;
  33.                 }
  34.             }
  35.             j++;
  36.         }
  37.     }
  38.     for (i = 0; i < amount; i++)
  39.     {
  40.         printf("%c%d ", arr[0][i], (int)arr[1][i]);
  41.     }
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top