fork download
  1. //This small prorgam removes all duplicated characters out of a string
  2. //Author dcc0@yandex.ru. 2018
  3. #include <stdio.h>
  4.  
  5. int
  6. main (int argc, char *argv[])
  7. {
  8.  
  9. //here we check arguments
  10.  
  11.  
  12. //it calculates an array's length
  13. int x;
  14.  
  15. char a[] = "rentgenoehlektrokardiograficheskogo";
  16.  
  17. for (x = 0; a[x] != '\0'; x++);
  18. printf ("Original lengh: %d\n", x-1);
  19.  
  20.  
  21.  
  22. //vars for cycles
  23. int i;
  24.  
  25. int j;
  26.  
  27. int z;
  28.  
  29. z = x + 1;
  30.  
  31.  
  32. //here we search twins
  33. for (i = 0; i != z; i++)
  34. {
  35.  
  36. j = i + 1;
  37.  
  38. while (j != z)
  39. {
  40.  
  41. if (a[i] == a[j])
  42. {
  43.  
  44. a[i] = '.';
  45.  
  46. }
  47.  
  48. j++;
  49.  
  50. }
  51.  
  52. }
  53.  
  54.  
  55. //here we count x to set a length of array c
  56. x = 0;
  57.  
  58. for (i = 0; i != z; i++)
  59. {
  60.  
  61. if (a[i] != '.')
  62. {
  63.  
  64. x++;
  65.  
  66. }
  67.  
  68. }
  69.  
  70. //here we write chars to c
  71. char c[x];
  72.  
  73. j = 0;
  74.  
  75. for (i = 0; i != z; i++)
  76. {
  77.  
  78. if (a[i] != '.')
  79. {
  80.  
  81. c[j] = a[i];
  82.  
  83. j++;
  84.  
  85. }
  86.  
  87. }
  88.  
  89. //here we print a result in array c
  90. c[j] = '\n';
  91.  
  92. printf ("%s\n", c);
  93. printf ("Number of uniqe symbols: %d\n", j-1);
  94.  
  95.  
  96. }
  97.  
  98.  
  99.  
Success #stdin #stdout 0s 4560KB
stdin
Standard input is empty
stdout
Original lengh: 34
nltdraficheskgo
Number of uniqe symbols: 15