Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<ctype.h>
- #include<string.h>
- int main() {
- int arr[255] = {0};
- char s[60] = "";
- printf("Enter string: ");
- gets(s);
- for(int i = 0; i< strlen(s); i++) {
- if(isalnum(s[i])) {
- arr[s[i]]++;
- }
- }
- int max = 0;
- printf("Times of appearance for each character:\n");
- for(int i= 0 ; i < 255; i++) {
- if(max < arr[i]) {
- max = arr[i];
- }
- if(isalnum(i) && arr[i] != 0) {
- printf("%c:\t%d\n", i, arr[i]);
- }
- }
- printf("Characters that appears the most: \n");
- for(int i = 0; i < 255; i++) {
- if(arr[i] == max) {
- printf("%c:\t%d\n", i, arr[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement