0 like 0 dislike
6.5k views
Write a program to count the highest occurrence of a single character in a string, Hint: This problem is only concerned with lowercase letters and single words, no sentences

example

input: aaaaaaaaaabb
output : 10

input: aaaabbbccccceeeezzzzzzz
output : 7
[Exam] asked in Midterm
ID: 23784 - Available when: Unlimited - Due to: Unlimited

reshown by | 6.5k views

47 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<ctype.h>

#include<string.h>

int main()

{
* * *** ** ****** * * *** *** * i, j, flag[26]={0}, max=0;
** * ** ******* * * * letter[26]={
* * ** ** *** * * * **** *** **** * * **    'b',
*** * * ** ****** ** ** * * *** * *** **    'd',
**** ** * *** * *** *** *************** *    'f',
* * * * ** * *** * ** ***** **** * *    'h',
* ***** * * *** * ** * * * ** *** ** *    'j',
* ** ** * ** * ** * * **** ** ** ******** ****    'l',
*** * * *** ** * * ** * * * ** ** *    'n',
*** * *** * * * ** * * *** **** **** *** *    'p',
*** * ** ** * **** ** * ** * * * ** ****    'r',
** ** ** ** * * **** * ** *** * ** * ** * * *    't',
** ** *** ** * ** * * * **** * * **** ***    'v',
* **** ****** * ** ** ** *** ** ** ** * ***    'x',
** * * *** ** * * * * * * **** * * ** *    'z',};
* * ** ** * * * ** s[100];


* ** *** ** * **** * *** ** *


******* * **** * ** ** ** ** * **
*** ** **** * * *** * * * * * ***** * ** * ** *** *
****** ** *** ** * ** *** * * * * * * * ** ** * ** ** * ** ** ** * ***
*** * * ** ** ** * * * *** ** * * ** *** * *** ** ** * * * * * * ** ** ** * ** * * *
* *** ******** * ** ** ** ** * * *** ** * **** * * *** **** * * ** * * * ****** ** * * ** * * * * * **
*** *** * * ** * ** ** ** *** * * *** ** * *** * * ** * ** ** **** *** * **** ** ***** *** * ** *** *
* ** ** * ****** * * ****** * * ** * *** ** * * ** ** *** ** ******* * *** ****** ** ***
** * * ** *** * ** * * * * ** ** * ** ** ** * ** * * * ** * ** * **
**** *** * *** ** * *** ** ****** **** ***** ** **
****** ****** ** * ******


** ***** * * * ** ** ** * **** *** * * max);
* ** * * *** * * ***** * 0;

}
answered by (-368 points)
0 like 0 dislike
Hidden content!
#include *** * ** **



#define MAX_SIZE 100 //Maximum size of the string



#define MAX_CHARS 255 //Maximum * **** allowed











int main()



{


*** * ** ** **** **** * * * *


* * * ** ** *** * * *** *** *** //Stores ** * * of each character


* * ** ***** ** * * * ** * i = 0, max;


* ** ****** * *** *** ascii;






*** ** * *** *** *** * **** *






* ** *** * * *** ** ** * ** * **** ** * of all ** * to 0 */


**** * ** * * *** * * *** * * * ** i++)


** * ** ******** ** **


**** ***** * *** * *** *** *** * * * ** * * **** * * = 0;


* * ** * * * * **










* ** * * ** ** * * *** Finds frequency of each *** */


** * ****** ** ***


** ** * * ** ***** * * * * * != '\0')


* * * ** * ** *


* * ** * *** ******** ****** * * *** *** * * = * ****** *


*** * ** ** *** * * * ** * **** * **** *** ** **** * += 1;






** **** * * *** ** * ** ** *** *** *


* * * * * *** *** **










**** **** *** * Finds maximum frequency */


** * * * ** ** ** ** **** = 0;


* **** *** ** * * * * ** ** * **** i++)


** * * * ***** ** * * * *


** * *** ** **** ** * ** * * ** * ** *** ** ** *** > ** *


* **** * * ** * * *** ** * * ** * * *** * ***** ** * ** * * * = i;


** ** * * * * *** ** * *










*** ****** * ****** * * * * * * *** *






** * ** * * **** ** * ** *** 0;



}
answered by (237 points)
0 like 0 dislike
Hidden content!
#include ** * *

#include * *** ** *** *

#include ****** ****



int main()

{
*** ** ** **** * ** * ** txt[1000];
** * * ****** * *** ** alp[26]={0}, i, max=0;


** ***** ** *** * * *** ** *** **** txt);


* * ** * * *** * i<strlen(txt); i++)
** * * * *** ** ** * *** * * ** *** ** * * **** *** ** *


** * ** * * * * * * ** i<26;i++)
* ** ** *** * *****
** * ** * * ** * **** * * *** ** * ** < alp[i])
*** *** ** * ** * * * ** * * *** **** * ** * * ** * ****** * *** = alp[i];
* *** *** ** * * * **


*** * * * *** * * **** * * *** * max);


* ***** * ** * *** * * 0;

}
answered by (5.2k points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

#include <string.h>



int main()

{
** ****** ** * * * * ** a[100000];
* ** ******** ****** * b[26]={0};
* ** **** * ** * * i,max=0;
* ** ** *** ** **** *** * *


* * ** * * * *** * *** * (i=0; i<strlen(a);i++)
* * **** * * * ** ** *
* ** ** * * * * * * ** ** ****** * * * *** ** ** * ** *****
** * ** ** ** **** *


* * ** * **** * *** ** ** i<26;i++)
* ** * **** * ** *
* * ** * * ** ** *** * * **** * * *** (b[i]>max)
* ****** ** * *** *** * * * ********* * **
* * ** *** ******* **** ** * * * * **** ** * ************** * * * *
** * * ** * ** * **** * * ** **
** * **** ** * * ** * **
***** *********** ** *** * * **** * ** *** * ** *


* * * *** ** ** ** *** 0;

}
answered by (-190 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>



int main()

{
* * * ** ** ** ** ** * a[100];
* ** ********* * i,max;
* *** ******* * **** ** b[26]={0};


* * **** ** ** ** * *** * *


** ********** *** * * *** *** *****

    {
* ** * ** * ***** ** *** * * ** *** ** * * ***
* * *** **** * * ** *
* ** ** ** * * * ** ***
** * ** * * ***** ** *** ** *** ***

    {
* * * ** * *** ** * * ********* * ** * * ** ** *
* * * ** ** ** ** * * ** * **** * **
** *** * **** ** *** * * * ** * * * * ** ** ** ***** *** **
* * **** *** ***** * *** ******* * ** ** ***
* * ** * * * ****
* * * * * ** * * * ** **** ** ** ** * * **

}
answered by (-226 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>

int main ()

{
* **** * * * ***** ** a[100];

    char j, b[26]={0};

    int i, k;
* ** ** ** ** * * * * **** * * ** *
** ** * * * ** * ** * *** ** * ** ** *

    {
** * * ****** ** * ***** ** * * * ** ** * ** *** *
* ** * * * ** *** ******* ***** ** ***** *** * * * *
* * * *** ** * * * ** * **** **** * **
** ** * ***** **** * * ** ** * * *** ** *** * * **** ** * * ****
* * * ** * * * *** *** * * ** * * ** *** ** **** * * *** **** ** *
***** *** * **** * *** * ******* * * * * * *** * ** * * * ** *** * * *** * ***** * * *** *
* * *** * * * *** * ** * * **** * * *** * ** * * ** * ** ******
* * * * *** * ** * ** ****** ** * * ** * ** ** *** *** * **
* * *** *** * ** * *** * ** ***** *** *** ***

    }

    int max=0;
* ***** * ** ** * * * * ** **

    {
* ** * * ** ** ** * *** *** *** * *** * *
**** **** * * * *** *** *** * * ** * * * * *
** ** * * * ***** ** * * **** ** * * ** * ** * * * ** * **** * * *
* *** * * *** * ** * ***** **** * * *** *

    }
* ** ** * ** ** * **** * * ** * * * *** * *
** * * * * * * ** * ** 0;

}
answered by (-367 points)
0 like 0 dislike
Hidden content!
#include ** * * *



#define MAX_SIZE 100 //Maximum size of the string



#define MAX_CHARS 255 //Maximum ** * allowed











int main()



{


** ** ** ** ***** * * * *** *** *** * *


* * *** ** * * **** * ** * //Stores **** of each character


*** ** ** ** * ** * * * i = 0, max;


**** * * **** * * * * * * ascii;






** * * ** * * ** * ***






** * * * ** * ** ** *** ** * of all ****** to 0 */


*** * **** * * * ** ** * * ** ** **** i++)


*** ***** * * *


* ** ** **** **** * * ** * * ** *** ** * ** = 0;


* ** * * **** ** ****










****** ** * ** ** ** Finds frequency of each * ** */


* * ** ** * ** * *** ***


** * ** *** * * **** ** * * != '\0')


**** * * ** * * * *


** *** ** ** ** ** * ** * ** ********* = **** ***


** * *** ** * ** ** * * * ** * *** *** ** += 1;






*** ** * * * ** ** * ** * * *** * ** ** ** * *


** * *** * ** *** *










** * *** *** * * * * *** Finds maximum frequency */


* * * ** ********* * * = 0;


*** ** **** * * ** ** * *** * * ** ** i++)


* * ** ** ** ***


** ******* * * * *** * ** ** * * * *** * **** ** > * **


* * * * * ** ** * * ** *** * * ****** * *** * *** ** * * ** ** * = i;


* ** ** * ******* ***










**** * ** * * ***** *** **** ** * ** *** **






**** * * * ** * * *** ** 0;



}
answered by (-215 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.214.204
©2016-2025

Related questions

0 like 0 dislike
13 answers
[Exercise] Coding (C) - asked Apr 21, 2017 in Midterm
ID: 24268 - Available when: Unlimited - Due to: Unlimited
| 2.4k views
0 like 0 dislike
11 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24270 - Available when: Unlimited - Due to: Unlimited
| 2.4k views
0 like 0 dislike
65 answers
[Exam] asked Apr 13, 2017 in Midterm
ID: 23786 - Available when: Unlimited - Due to: Unlimited
| 8.7k views
0 like 0 dislike
8 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24273 - Available when: Unlimited - Due to: Unlimited
| 1.6k views
0 like 0 dislike
4 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24272 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
12,783 questions
183,442 answers
172,219 comments
4,824 users