0 like 0 dislike
1.8k 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
[Exercise] Coding (C) - asked in Midterm
ID: 24268 - Available when: Unlimited - Due to: Unlimited
| 1.8k views

13 Answers

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

#define MAX_SIZE 100

#define MAX_CHARS 255



int main()

{
****** ** ** ** ** ****** * string[MAX_SIZE];
* * ******* *** * * frequency [MAX_CHARS];
*** * * * ** ** * i=0, max;
**** * * * * * * * ascii;
* ** ** **** * *** ** * ****


* ** * ***** * * * i<MAX_CHARS; i++)
* * * * * * * **** *
** * * * ** ** * ** * *** * * ** * ** ** * * ** * *****
**** *** * * *******


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


* *** *** ** ** ****** =0;
* ** *** ** * * ** ** * ** i<MAX_CHARS; i++)

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



    }
* * *** ** ** * * ***** * ** frequency[max]);
* ******* ** * * * * *** 0;

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

#define MAX_SIZE 100

#define MAX_CHARS 255



int main(){
** **** * * * * * string[MAX_SIZE];
* * * ** * * * * times[MAX_CHARS];
* * *** * * * ** * * *** i = 0, max;
***** * * * * *** * *** count;


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


* * ****** * * * * * * ** i<MAX_CHARS; i++){
****** **** *** * * ** * ** * * ** * **** * ****** = 0;
** * ** * ** ** * * *
* ** * * ** ** ** **


** ** * ** * ** ** ** != '\0'){
* ** *** ** * *** * * * **** * * * ** ** ** = (int)string[i];
* * ** * * *** * ** ***** ** * * ** ** **** += 1;
* * *** * *** *** * * * ** ****** ** * * ** *
* ** * * ** * *


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


* ** ** * **** **** * ** *** i<MAX_CHARS; i++){
* * * * **** * ** *** * **** * ** * * *** > times[max])
** * * **** ** ****** ****** * * * **** ** ** * * * ** = i;
****** *** ***** ** ** ** ****
* * ** *** ****** ** *** * ** ** * *** ** * *


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



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

#include <string.h>

#define MAX_STR 50



int main(void){

    int c1=1, c2=0, i;

    char a[MAX_STR];


**** * * * * * * * * ** **** *** * * a);
****** * * ** ** * **** * * * i<strlen(a); i++){
* * ** * * *** * *** ******* * ** ****** ** * ** * * * * *
**** * ** ***** * * * *** * ** * * * * * * *** * *** * *** *** * ****
* ** * * * ** ** ** *** * * ** * * * **
* **** ** * * ******* ** * * * ** ** * * * * * ** * **** ******** **
***** *** **** *** *** * ** ****** * * * ** ** * *** * **** * ***** * ** * * * ** * ** * *** *
** * ******* * ** ** ****** * ** **** * ** ** ** * ** *** * * *** * *** * ** * * *** * ** *
*** ** *** * ******* ** * ** * ** * **

    }
* * ** * ** ******* ** * *** **
* *** * * *** ** * *** * ** ** * ******* *** ** * * * c2);
**** ** ** * **** * ** * ***
* * * * * * * ** ** * ** * * **** * * ** *** * ** c1);


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

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

#define MAX_SIZE 100

#define MAX_CHARS 255



int main()

{
*** ** * **** ** ***** string[MAX_SIZE];
** *** * *** * * ** * ** * * frequency [MAX_CHARS];
* **** * * * ** * ****** * i=0, max;
* * * ** * ********* ** **** * * ascii;
** ** * *** **** * ** * * *


***** * * ** ** * * ** i<MAX_CHARS; i++)
* ** ** * * *
* * * * ***** * * * * **** * *** ** **** ***** * **
** ** * ** ***** *


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

    
** ** ********* ** * * ***** =0;
***** * ****** * *** i<MAX_CHARS; i++)
**** * * * **
* ** * * * ** * * *** ** **** ** ** ** *** * ***** ** * *
*** * **** ** **** ******* * * ******* * * * * * * *



    }
** * ** * * * **** ** frequency[max]);
* ** ** * * ** ** * * 0;

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

#define MAX_SIZE 100

#define MAX_CHAR 255





int main()

{
*** ** * *** * * ** ** *** string[MAX_SIZE];
* * * ** * ****** ** ** frequency[MAX_CHAR]; int i = 0, Max; int ascii;


* ***** ** * **** **
* * ** * ** ******** ***** ** * i<MAX_CHAR; i++)
* ** * ***** **** * *****
* **** ******** ** * ** ** * ** ** * * * * * ** * * = 0;
**** * *** * * * *


* * ** * *** * * ** *
* * **** *** ** * *** * ** * * != '\0')
* ***** ** * **********
** ** ** ***** * * * * **** ** * ***** **** = (int)string[i];
* ** *** * ** * ** * * ** * * * *** ** += 1;


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






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


*** * ** * * ***** *** * i<MAX_CHAR; i++)


* *** *** ***** * ** *
* * ** ** ** ** * *** ** *** *** ** *** * ** * ** * > frequency[Max])


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




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


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

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

#define MAX_SIZE 100

#define MAX_CHARS 255

int main()

{
* ** ** * * ** * **** ** string[MAX_SIZE];
** ***** * * ** ** * * freq[MAX_CHARS];
* ** *** * ******** i = 0, max;
** ** * * * * ****** ascii;
** *** ** ** * **** *** ** *
* * ** * * *** * ** * ** i<MAX_CHARS; i++)
** ** * *** **** * **
* *** * ***** * **** *** * * *** *** **** * = 0;}
** *** * ** * * * *
* * *** * ** ** *** **** * * * * ** !='\0')
****** **** * **** **** * * *
** ** ** ** * * ** * ** * *** ** * * * * * = (int)string[i];
***** * ** * ** *** * **** * * ** * ** *** += 1;
* ** ** ** ** ******** ** ** *** ** *** * * ** * ** * *
**** ** * * *** * ******* = 0;
* ***** ** * * i<MAX_CHARS; i++)
* ** ** * *
** ** * *** * * * ** * * * ** *** * *** *** * ** > freq[max])
***** ***** * **** ** *** ** * ******** * * **** * * ** **** = i;}
* ** ** * *** ** * **** * * ******* ****
**** * * * * * ** 0;
* *** ** ** * ** *** * * **
answered by (38 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#define MAX_SIZE 100

#define MAX_CHARS 255

int main()

{
** ***** * **** * * ** * *** string[MAX_SIZE];
* ** ** * *** ***** ** freq[MAX_CHARS];
* ** ** * **** *** **** *** i = 0, max;
* *** * * ** **** * ascii;
* *** **** ** * * **** * * *
* * ** * ** * ***** i<MAX_CHARS; i++)
* * * *** *** ** * * *
****** *** * **** * *** * ** ** * *** ** ***** = 0;}
** * * *** ** *** **
* ** * * * * * ** ** * * != '\0')
*** * ** *** * ** *** ** **
* *** **** ** ** ** * * ** ** * ** ******* * ** = (int)string[i];
* * *** * ** *** ** ** **** ** * *** * * *** * * += 1;
* ***** **** * ** *** * ** * * *** * * ** *
* *** ****** * * * *** ** = 0;
** * * * * ** * * ** * *** i<MAX_CHARS; i++)
* * **** * *** ** *
*** * ** *** *** * * *** * * * * > freq[max])
*** ***** ** * ** * ****** *** * ** ** * **** * = i;}
* * ***** *** ******* ****** * *** * * **
*** ** ** * * * ** * 0;
answered by (38 points)
0 like 0 dislike
Hidden content!
#include ****** ***

#define MAX_SIZE 100 //Maximum size of the string

#define MAX_CHARS 255 //Maximum characters allowed



int main()

{
** * * ** * * * ** * ** string[MAX_SIZE];
** ***** ******* * * ** * * frequency[MAX_CHARS]
* ***** ** * * **** * * ** i = 0, max;
* * ** * * ** * * ascii;
***** * * *** * * * * *


* * ***** * ** ******** i<MAX_CHARS; i++)
* * ** * ** ** ** *** * **
* *** * ***** * * ** * ** * ** * * * *** **** ** = 0;
* * *** * ** **** *


***** * ** * * **
* * * * * * * * != '\0')
**** *** ** * ** ** ** *
* *** ** * **** *** * * **** * ** * ** **** = (int)string[i]
* ***** *** ** * ** **** * * * *** ** * *** ** += 1


* * ** * * * **** **
* *** * * **** ** * * *
* * ** ** ** **** = 0;
* * * * * ******* *** ** ****** * i<MAX_CHARS; i++)
* * ** ** ** ** **
****** **** *** * * *** * * * *** ** *** ** * ** **** > frequency[max])
* * * ** ** * * *** * ** ***** *** ** * *** * * *** ** * ** ** * = i;
* * *** ** *** ****
** * **** *** * ** *** * *** ** * * * * * * *
***** * *** * *** * 0;

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

#include ** * ** *

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

int main(){
** * * * * ** ** * i, j;
* *** * * **** * * ** * word[100];
* * * * ***** * *** * lenght = 0;
* ** ** * *** **** *** max = 0;
* *** * ** *** * *** ** counter[26] = {0};
* * ** * * * * ** *** Alpha[26] = {'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'};


****** * * ** ** * * * * * ** ***** ** ** ** word);
********* * ******* * ** ** *** = strlen(word);
* ** * * * ** * *** ***** * * * * lenght);
** * ***** *** * * * * **** i++){
** * **** **** * * ** ** * * * ** * ** ** * j<26; j++){
**** ** * * * * * ** ** * * * **** ** *** *** ***** * ** ***** == Alpha[j]){
**** * **** * * ** ** *** * ** * ** * **** * ** * *** * ** * **** ** ** ** * *** * * * * * *** * *
* *** ** ****** ** * * **** **** * ** * **** ** ** * ***** * * *
* * ** * **** ******* * * * *** *
*** * * * ** * **


* ** * * ** ********* i<26; i++){
* * * * * * * ** **** * **** ** * * * * * * > max)
* * * ** ***** * ** * * ** * * **** ** **** ** * ***** ** * * = counter[i];
* * * * *** * ** *


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


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

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


**


* ** *
** num ** = * *
** i;
*** max =0;


* * **




( ** ** * * *
* **** ***


* * * ***** *

if *** num *
** * ** ** *** * * * ** * *

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


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

Related questions

0 like 0 dislike
11 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24270 - Available when: Unlimited - Due to: Unlimited
| 1.8k views
0 like 0 dislike
47 answers
[Exam] asked Apr 13, 2017 in Midterm
ID: 23784 - Available when: Unlimited - Due to: Unlimited
| 5.2k views
0 like 0 dislike
8 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24273 - Available when: Unlimited - Due to: Unlimited
| 1.3k views
0 like 0 dislike
4 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24272 - Available when: Unlimited - Due to: Unlimited
| 948 views
0 like 0 dislike
6 answers
[Normal] asked Apr 21, 2017 in Midterm by thopd (12.1k points)
ID: 24271 - Available when: Unlimited - Due to: Unlimited
| 1.1k views
12,783 questions
183,442 answers
172,219 comments
4,824 users