0 like 0 dislike
923 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 | 923 views

47 Answers

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

#include<string.h>



int main(void)

{
** * * ** * * in[100];
** * *** *** * * * count[26],l;
** * ** * * * ** **** * * * *
** ** * * ** *** * ** ** ******* * * * ** *** ***
* ** ** * ** ** * ** * **
** * * *** *** * **** ** i,max=0;
* * * ** * * * * * *** *
******** * ** ** ***
* ** * * ***** *** ** * * **** *** * ** * ** *
* ** * * * ** *** *** * **
* ****** ****** * * * *** * ** * **

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

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

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

#include <stdlib.h>

#include <string.h>



int main()

{

    char A[100];

    int i, len, count1 = 0, count2 = 0, temp = 1;


*** *** *** ** ** *** * * ***** * * A);

    len = strlen(A);

    for(i = 0; i < len; i++)

    {
* **** * * * **** * ** * * * * * *** * ****** == A[i+1])
**** * * * * *** ***** **** * * * * * * * ** ** **** ** ***** * *** *
* ****** * * ******* * * ** * * ** *** *
*** ****** * **** ** **** * ** * *** **** * *
* * * ** ** * ** * * * ** ** * * * *** * *** * * ** * * ***** *** * * == 0)
** *** ***** *** *** * *** * ** * ***** ** ** **** *
** * *** * * * ***** * * * ** *** ***** ******** * * **** *** * ** * ** * * ***** *** * * ** = temp;
* * * ** ** * *** * ** ** ** ** * * ***** * ** **** ****** * * * * * * ** *** = 1;
* * * * **** ** * * ** * ** * ** * * * * ** *** **
* ** * * *** **** * * ***** ** ** * * **** * *** ** * *
*** ** * * * * * * ** * **** * * * ** ** **** ** * **
** *** ** * ****** * ** * * ***** * **** * **** * ** * **** *** ******* * **** * ****** = temp;
***** * * ** ****** **** ** * ** **** * ** * * * *** ** *** * * *** ** * * * = 1;
* *** ** * ** * **** * ** **** * ** * * ***** * ** * *** * **** *
* **** * * * ** **** *** ** * * ** * *** * ** **** ** ** *** * < count2)
** * ** ** ** * **** *** * *** ** ** **** * **** * *
* * ** * *** *** ****** ** * * ** **** ** ***** * **** **** * * * * ** * **** * ***** * * = count2;
*** * * **** ** * ** * * ** * * ** * *** * ** * ** ********* ** * ** *** ** = 0;
* ** * * * * * * ** ***** * * ** * * * *** * **** *** * * * * * ****
** * * * * *** * * ** ***** * * * ** *****

    }
* * ** ** * ** * ********* *** * * ** *** ** * count1);

    return 0;

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

#include <stdlib.h>



int main()

{

    char A[100];

    int i, len, count1 = 0, count2 = 0, temp = 1;


** * **** * ** * ****** * ** A);

    len = strlen(A);

    for(i = 0; i < len; i++)

    {
** ****** * *** * * * **** *** * * * * *** == A[i+1])
* * ** ** * * ******** * * * * * * * * * **** * ** * * ***** **
*** * * ** *** * * ** * * *** **** *** ****
* * **** * * *** * *** **** ** *** * ** *****
* * * *** * * * * ***** * ***** * **** * ** ** **** == 0)
******** ** * * * **** * ** **** * * * * * ** * * ** * *
* ** ** ** * * *** * * * * * * **** ** * **** * * * ***** * * *** * * * **** *** *** = temp;
* * ** ** * * ** ** ** * ** **** * * * * ** * * * ** **** * * * * * ** *** * **** ***** = 1;
** * * ************* * * * ***** * ** ** *** * * * **** *
****** * ** * * * ** * **** * ** ******* * * * *** * ** *** ***
** *** **** * * * *** ** * *** **** * * ** ** ****** ** ** *
*** * *** * **** *** ** ** * * **** ** * * ** ** * ** * * ** * ** ** * * * * * * ** *** = temp;
** * * ** ****** **** * * * ** * * * ** * * ******** ** ****** *** ** ** * *** *** * = 1;
*** ** * ** ** * * **** ***** ** * ** ****** * ** ** ** *
* * *** * ** * * **** ****** * * **** * * * ** * ** * * ** **** * < count2)
* * * * * **** *** ** * * * * * * ** * * *** * *** ** ** *
***** * ** ** * ** * ***** * * * ** * * * * * *** * * * * * * *** **** *** *** = count2;
* * ** *** **** * * **** ****** **** * ** ** **** * * * * ** ** *** ** *** ** = 0;
***** * * * * ** ** ** * ** * * * ** * ***** *** * ** * ****** * ***
* ** * ** * ** * * * * ** ** ** ** *

    }
***** *** *** *** *** * ** *** * * *** ***** count1);

    return 0;

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

#include * **** **



int main()

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


** * *** ** * **** * * *********** *** a);


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




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

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

#include<string.h>



int main(void)

{
* * ** ** ** ***** * ** ch[100],i;

    int j,a[26]={0},k=0,max=0;
* * *** * * *** ** * ** *


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

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

    }
* ** *** * ******* * * * * *

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

    }
* ** * ** * * **** ** * ** * ** *

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

#include <string.h>



int letter[34]={0}, i, j, max;

char word[50];



void C(void);

void M(void);



int main(void){
* * * ** *** ** * *** ** * * * ** word);
* * ****** ** ***
** * * * * * ** *******
* *** **** **** * ** ******** ***** max);

}



void C(void){
* * ** * * ** ** * * i<strlen(word); i++){
* *** *** * *** * ** * * * ** * * * ** * * j<='z'; j++){
* ***** **** * * ** * ** ******** ** ** * * * ** **** ** ** * * ** ** ***
* * *** ***** ** ** **** * * ** ******** ** **** * * * * *** * * * ** * * * * * * * * * * * ** * * *
* * * ** * ******* * ** * ******* ** * * * *** **** ** * * ** ** * *** *** *** * **
**** *** **** ** * * ****** ** ** *** *** * **** * **
* *** * * * * ** * * ** ****** *** * *
** ** *** * * * * ** * * ***** * *** j<='9'; j++){
*** * ** * *** ** * *** *** * ** ***** * *** * * * * * *
* * * * * ** * **** ** * ** ** ** ** * * * * *** * **** * *** **** **** * * * * ** *** * * *
** ** * ** * * * * * * ****** * * *** **** *** ** * ** ** ******** ** ***** * * *
* * ** ** *** ** ** *** * ** ** * ** * * ** * *** * ***
* * * *** * *** ***** ****** * * *** * * *

    }

}



void M(void){
* ** ***** ** * ***** ** max=letter[0]; i<34; i++){
**** *** * **** ** * ******** * * ** * **** ******* * * max=letter[i];

    }

}
answered by (-581 points)
0 like 0 dislike
Hidden content!
* ** ** * *
*** *** ** * **



int main()

{
* *** * **** ** * * * * max = 0, ii, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
* ** ** ** ** ** letters[26] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
* ***** * ***** * * input[100];
* * *** *** ** ** * *** * ** * ** * **
* * ** * * * ** * * ** * (ii = 0; ii < **** ** * ii++)
****** *** * ** ******
*** * **** * **** *** * * * ** ** **** **** ** ** * (input[ii])
****** ** * ** * * ** **** ** ***** * ** **
* ***** * ** * *** * * ** * *** ** 'a': letters[0]++; break;
** * * * * ** **** * * * ** * **** *** ** * * 'b': letters[1]++; break;
** * * ** **** *** *** * ** *** * * *** ** * ** 'c': letters[2]++; break;
* * **** * * * * * * ** * ***** * ** ** *** 'd': letters[3]++; break;
*** *** * * * ** * ** * ***** *** ** ** ** * 'e': letters[4]++; break;
* * * *** * * * *** * ********* ** ** ** **** 'f': letters[5]++; break;
* * ** *** *** **** * ** * * * * ***** ** 'g': letters[6]++; break;
* * ** * ****** * *** ***** **** ******* 'h': letters[7]++; break;
* *** * * * * * * * ** * * * **** *** ** 'i': letters[8]++; break;
* ***** ****** * * ***** ******* ** * ***** * * 'j': letters[9]++; break;
* ** * * ** ** *** * * ** *** * 'k': ** break;
**** * * ** ** ** ** * ****** * **** * 'l': * **** break;
** * ** ** ***** * *** * *** ** *** * *** * 'm': * ** ** break;
** *** * * ** * ***** * * ** ****** * *** * 'n': * * ** break;
* ***** ** *** * * * * ** * * * * * * * ** ** * 'o': * * * * break;
* ** * * * * ** * *** * ** * ** ** * **** * 'p': * ** *** break;
** * ** ** * *** * * ** * * *** ** 'q': * * * break;
** * **** *** * * * *** * ** *** * ** 'r': letters[17]++; break;
** *** * ***** ***** ** * * * ** * 's': * ** break;
*** *** ** *** * * * ****** * ** ** * * * 't': ** **** break;
** * * * * ** ** *** * * * ** * ** ** * ** 'u': ** ** ** break;
** **** ** ** ** ******** ** * * * * ** 'v': * *** *** break;
** * ** * *** ** ** ** *** * * * * **** **** ** 'w': * * * * ** break;
* * * ** ** * * * * ** * * * * ** * * 'x': * ******* break;
** *** ***** * **** * *** ** ** ** ***** *** 'y': * **** break;
*** * * * **** * * ****** *** * ** **** 'z': *** ** * break;
****** ** *** * * * ***** **** ** * ** *
*** **** **** * ***** ***
* * * **** * * = letters[0];
** * * ** * * * * (ii = 1; ii < 26; ii++)
* * *** * * ** * * *
* *** * *** ** * * *** ** * * * ** *** (max < letters[ii])
* **** ** ** * ***** * * ** ** * * ** * * * *** * * * ** * * * *** = letters[ii];
* *** *** * * * * * *


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

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

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



int letter[24]={0}, i, j, max;

char word[50];



void C(void);

void M(void);



int main(void){
*** * * * ** * * * * * ** *** * word);
* * ***** **** *** ****
**** * * * ** *** *** * * *
* * ** * ** * * * ***** ** * * ** * max);

}



void C(void){
** * *** *** * ****** * * i<strlen(word); i++){
**** *** **** **** *** ** * * * * * ** **** j<='z'; j++){
* * ** * * *** * ** ** **** *** ******* * ** ** * **** **** * * * *** * * *
** * *** ** * * ** ** * * ** ** ** ** * * * ** * * * * ** * * ** *** ** * ** *
* * * **** ** ** * ******** ** * * * **** ** * *** * ** * ** ** **** * * *** * ** **
*** * ***** * * * ** * *** *** * * ***** * **
* * * ** **** **** * * ** ** *** *
*** ** **** ** **** **

}



void M(void){
*** ***** *** * * * **** * ** max=letter[0]; i<24; i++){
** * *** **** * ** * * ** ** * ** *** * *** *** **** max=letter[i];
** * **** * ** * * ** * * **

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

#include<string.h>



int main()

{
*** * * * * ** * * * ** i,max=0,len;
***** *** ******* * * a[100]={0};
*** ** * *** ** * b[26]={0};
** ** * ** ***** ********* ** * * ** * *
** ** *** * ** * * **
*** * ** ** **** ** * i<len; i++)

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

    }
** *** * ** * **** * * * * i<26; i++)
* * * ****** * ******
* *** ** **** * * ***** *** ***** * ** * * **** *
* * ******* * * * ** ** * * ** * *
***** *** ******* *** **** * * ** * *** * *** ******* ** ** *****
* ** * * *** * *** ** ** ** * *** ** **** * ***
* * ** ** * **
** * *** ** * * ********* ** * ** **** *
***** ** * * * ** *** 0;

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

#include <string.h>



int main()

{
** *** ***** ** * ** * a[100];
* * ** *** *** ** length,i,highest=0,b[100]={0},j;
*** ** *** *** ** * ** * * * * &a);


* * * * *** * *** *** * * = strlen(a);
****** * * * ***** ** * ** = 0; i < length; i++)
* ** * * * ** ********
**** *** ** * * * * * * *** * * ** **** = 0; j < length; j++)
* ** * * * * * **** * * ** * ** ** * * *
**** ***** * * ** ********* * *** ** ** * *** * **** **** **** ** * * ** * == a[j])
*** ** ******** * * ** ** ** * * ** * * * *** ** **** * * ** * ** *
* * * * ****** **** * * ** * * * ** * *** * * ** ***** ** * * ** * ** ** ** *** * +=1;
*** ** * * * *** * * * *** * * *** **** ** *** ** ** * *** * * ** *
*** * * * * * **** ***** ** * * ** *

    }


** ***** * *** ** ** ** = 0; i < length; i++)
* * * ** ** **
* *** ** ** **** ** ** * **** ** ** ** * * ** *** < b[i])
** * * * *** ** * ** ** * * * * ** * * *
* * ** **** ** * * ** ***** *** * ***** * * * * * * *** ****** * = b[i];
* ** * ** * ** *** * * ** *** *** * **** *****

    }


** ** * * * * ** * * *** * * **** ** ** * ** * highest);








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

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

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
| 344 views
0 like 0 dislike
11 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24270 - Available when: Unlimited - Due to: Unlimited
| 277 views
0 like 0 dislike
65 answers
[Exam] asked Apr 13, 2017 in Midterm
ID: 23786 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
0 like 0 dislike
8 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24273 - Available when: Unlimited - Due to: Unlimited
| 235 views
0 like 0 dislike
4 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24272 - Available when: Unlimited - Due to: Unlimited
| 187 views
12,783 questions
183,443 answers
172,219 comments
4,824 users