Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<ctype.h>
  3. #include<string.h>
  4. int main() {
  5. int arr[255] = {0};
  6. char s[60] = "";
  7. printf("Enter string: ");
  8. gets(s);
  9. for(int i = 0; i< strlen(s); i++) {
  10. if(isalnum(s[i])) {
  11. arr[s[i]]++;
  12. }
  13. }
  14. int max = 0;
  15. printf("Times of appearance for each character:\n");
  16. for(int i= 0 ; i < 255; i++) {
  17. if(max < arr[i]) {
  18. max = arr[i];
  19. }
  20. if(isalnum(i) && arr[i] != 0) {
  21. printf("%c:\t%d\n", i, arr[i]);
  22. }
  23. }
  24. printf("Characters that appears the most: \n");
  25. for(int i = 0; i < 255; i++) {
  26. if(arr[i] == max) {
  27. printf("%c:\t%d\n", i, arr[i]);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement