fork download
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include<string.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. char string[128]="This is a test you know!",tempstring[128];
  10. char temp, smallchar;
  11. int c = 0, count[128] = {0};
  12. int n, i, j, k, l=0;
  13.  
  14. printf("Original String: %s\n ",string);
  15.  
  16. n = strlen(string);
  17.  
  18.  
  19. for (j=1; j<n; j++)
  20. {
  21.  
  22. for (i=0; i<n-1; i++)
  23. {
  24.  
  25. if (string[i] < string[j])
  26. {
  27.  
  28.  
  29.  
  30. temp = string[i];
  31. string[i] = string[j];
  32. string[j] = temp;
  33. }
  34.  
  35. }
  36.  
  37. }
  38. printf("\n Highest Number: %c\n", string[0]);
  39.  
  40.  
  41. for(k=n-1;k>=0;k--){
  42. if(l==0){
  43. if(string[k]!=' '){
  44.  
  45. smallchar=string[k];
  46. l++;
  47.  
  48. }
  49. }
  50. }
  51.  
  52. //Ikkada string in trim chey
  53.  
  54. printf("Lowest Char: %c", smallchar);
  55.  
  56. printf("\nDescending Ordered String: %s\n", string);
  57. for (i=0; i<n-1; i++)
  58. {
  59. if(string[i]!=' '){
  60. for (j=i+1; j<n; j++)
  61. {
  62.  
  63.  
  64. if (string[i] > string[j])
  65. {
  66. temp = string[i];
  67. string[i] = string[j];
  68. string[j] = temp;
  69. tempstring[j]=temp;
  70. }
  71. }
  72. }
  73. }
  74.  
  75. printf("\nAscending Ordered String:%s\n", string);
  76. printf("\nTemp String:%s\n", tempstring);
  77.  
  78.  
  79. while ( string[c] != '\0' )
  80. {
  81. /* Considering characters from 'a' to 'z' only */
  82.  
  83. //printf("String: %c\n",string[c]);
  84.  
  85.  
  86. if ( string[c] >= '!' && string[c] <= 'z' ) {
  87. count[string[c]-'!']++;
  88. // printf("String count: %c\n",string[c]-'a');
  89. }
  90. c++;
  91. }
  92.  
  93. for ( c = 0 ; c < 128 ; c++ )
  94. {
  95. if( count[c] > 1 )
  96. printf("%c occurs %d times in the entered string.\n",c+'!',count[c]);
  97. }
  98.  
  99.  
  100. printf("\n");
  101. return 0;
  102. }
  103.  
  104.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Original String: This is a test you know!
 
 Highest Number: y
Lowest Char: !
Descending Ordered String:  ywuttsssoonkiiheaT!     

Ascending Ordered String:     !Taehiiknoosssttuwy

Temp String:�yyyyyyyyyyyyyyyyyyyyyyy�?L�~��
i occurs 2 times in the entered string.
o occurs 2 times in the entered string.
s occurs 3 times in the entered string.
t occurs 2 times in the entered string.