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

47 Answers

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

#include<stdlib.h>

#include<string.h>

int main()

{

    char a[100];

    int max=0,i,j,l,count=0;
* ** *** * ** * * * * ** **** * * * * * ***
**** * * ****** * * *** ****** *
* * * * ***** ***** * *** * ***

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

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

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

int main()

{

    char a[100];

    int max=0,i,j,l,count=0;
** *** * * ** * * **** * ** ** * * *

    l=strlen(a);
*** * * * * * * **** *

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

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

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

#include<stdlib.h>

#include<string.h>

int main()

{

    char a[100];

    int * *** * **** * * **
** * *** *** * *** * *

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

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

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

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

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

#include <stdio.h>

#include <string.h>

int main(){
****** * ** ** ** * * a,b,c= 1,d=0,i;
* ******** ** * * ***** ** * s[50];
** * ****** * * * ** * * *** ** ** * * ** ** ****
** * *** * *** ** ** = strlen(s);
* * ** ******* * ** * (i=0;i<=b;i++){
* * * ** * * * **** *** * ****** *** **
** ** **** * * *** * * * * * * * * *** ** *
* * ** ** * * * ** * * *** *** * ** * (c > d)
* ****** * ** * *** *** * ***** ** = c ;}
** * * ****** * ** *** ***** * * * *** * * *

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

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

#include<stdlib.h>

#include<string.h>

int main()

{

    char a[100];

    int c=1,len=0,count=0,i,compare[100]={0},max=0;
***** * * * * ** * * ** ** ***

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

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

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

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

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

int main ()

{

  char a[130]={},w;

  int i,l,s[30]={0},max=0;

  gets(a);
* ** *** * ***
** ** *** ** **** ** * ** *

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

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

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

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

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

#include <stdio.h>

#include <string.h>

int main(){
** *** * * * * * * a,b,c= 1,d=0,i;
* * *** * * * **** s[50];
* * * **** * ** ** * ** *** * ** **
* ** * * ** * = strlen(s);
** * **** * * * ** (i=0;i<=b;i++){
* *** ** * * ** **** * **** * **** * * * ** * ****** * *
*** *** * ******** **** * *** * *** * ** *
* * * * *** * * ** * * * * ** * * (c > d)
**** **** * * *** ** * *** ** * *** * * **** = c ;}
** *** ** * * *** * * * ** * * * *

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

}
answered by (-136 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;
********** ** ** *
* * ** * * ** **** * * *****
* **** * *** * * * * *** * != '\0')
* ** * * *** * ***
* ** * * *** *** * * * ** * *** ** * * * * *** * = (int)string[i];
*** * **** *** *** * * *** ** ** * * *** ** * **** * += 1;
****** * * * * * ** ***** **** * * ** ***
** ** ** ** ** ** * ***
* * ** * * * * ** = 0;
* ** **** ** * * * * * ** i<MAX_CHARS; i++)
** * * * * ***** * * * * *
* * *** * * * * * ** * ** **** * * **** * ** * * ** > frequency[max])
* * * ********* ********* * * ** * * ** ** ** * *** ***** ** * * ** ** = i;
*** * * * *
* *** *** * ******** * * *** * *** * *** * *
** *** * ** * ** * *** * 0;

}
answered by (6 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;
** * * * * *** ****** **
* * ******* *
** ***** * *** ** **
*** ** **** * *** *** **** * * * ** != '\0')
* ****** * ** * **
* * *** * * * * * *** ****** * * * **** = (int)string[i];
*** ** * ** ***** * * * * ** ** ** **** *** **** **** += 1;
* ** * * ******* *** ** * * *** ** ***** * ** *** *
* * ** *** * * * *** ** **** * *** * * ** ***
*** * ******** * *****


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

}
answered by (126 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)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.17.84
©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
| 1.5k views
0 like 0 dislike
11 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24270 - Available when: Unlimited - Due to: Unlimited
| 1.4k views
0 like 0 dislike
65 answers
[Exam] asked Apr 13, 2017 in Midterm
ID: 23786 - Available when: Unlimited - Due to: Unlimited
| 5.6k views
0 like 0 dislike
8 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24273 - Available when: Unlimited - Due to: Unlimited
| 1k views
0 like 0 dislike
4 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24272 - Available when: Unlimited - Due to: Unlimited
| 752 views
12,783 questions
183,442 answers
172,219 comments
4,824 users