0 like 0 dislike
1.2k 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 C
ID: 22017 - Available when: Unlimited - Due to: Unlimited
| 1.2k views

52 Answers

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

#include <string.h>

 

char string1[100], visited[100];

int count[100] = {0}, flag = 0;

 

int main()

{

    int i, j = 0, k = 0, max, index;

 
*** * *** ******* * *** * * ** ** * * string1);

 

    for (i = 0; i < strlen(string1); i++)

    {
** ** * ** * * **** **** * ** * **** (i == 0)
* ******* * **** ** ****** * ** * * **
* *** ** ** * ** * ** * *** * * * * * * * *** **** * *** * = string1[i];
** **** * * * ** * ** * ** * ** ** ***** ***** * *** * * *** - 1]++;
** *** ** **** ** * ***** *** ** * * ** *** ** * ****
* ***** ** ** ** * * *** * * ** * *** * **
* * **** *** ** ** * * ** * * * * ******
* * * * ** * ** ** * * * ** ** * ***** * * *** ** (k = 0; k  < j; k++)
** * **** *** * *** ** * * * * * ** * * *** ****** * * *
** **** * * * ** * ** * *** ** **** ** ** * * * * * ***** * * * *** * * ** * ********* * (string1[i] == visited[k])
* ** * ** * * * * * ***** **** * ** ** * ** *** ** * * * ** * * *** * *** ***
*** * * * ** * * * * * * * *** ** ** * **** * ** * * * * * * ** *** ** ** **** ** * ** *** * ** *
* * * **** *** * * * ** * **** ** * *** ** * **** * ** * * ** * * * ** * ** ** * *** * *** * **** ** ** = 1;
* * ** *** *** * **** *** * * ** *** * * ***** * * * ** ** **** * *** ****
*** * ***** *** ** **** * * * * * ***** * ** * * ** * * ** * *** *
* * ** * ** *** * ** * * **** * * ** * **** ***** ** * *** (flag == 0)
** * ** ** * * * ** ** **** * * ***** *** ** * *** * ***
* *** * * *** ** ** * ****** * * * * * ** ** * ** ** * ** * * ** * * **** = string1[i];
* * ** * ** ** ** * ** * ** * ** * ** *** *** *** * * ** * * ** * ** ** * ** * * ** * ** * - 1]++;
** ** ** *** * ** * * *** *** *** * * *** ** ***** * ********* *** * ****
* ** * **** * * ** * * ** **** * * **** * * *** * * ** **** = 0;
******* * ** * *** * * *** * *

    }    

 

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

    {
***** ********** * ** *** **** * ** * ** * ((i == 0) && (visited[i] != ' '))
* ** ** * * * * * * * ** * * * *** **
* * * ** ** * * ** ** * ** ** ** ** ** ** * ***** * * * ** = count[i];
** ** * **** * ** * * * *** * * * * * * * ***** * *** *
* ** * **** * * * * * * ** ** * ** *** **
**** * * ** * ** **** * * ***** * ** ((max < count[i]) && (visited[i] != ' '))
* * ** * ****** * * * * * * ** *
* *** *** * ***** ** * * ***** *** *** * ***** * ** *** * = count[i];
**** *** ** *** ** ** ** * ** ** ** **** ** * * **** * ** ** * = i;
* ** ** *** * ** * ** ** * * ** *** ** **

    }
******* ** *** ** * ** * ***** * * count[index]);
**** *** * **** ** * ***** * 0;

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

#include <stdlib.h>



int main(){
***** * ** ** * * * ** ** i;
* * ** * * *** * * * * * *** a;
** * * ** *** * *
* * * * ** ****** ** * ** c[26]={0};
***** * ** * ** ** * * * *** ** *** *
* * * * * **** ** ***
**** **** ** * * * *** ****** ** ** ** * * **
* ** ***** ******* ** *** *** * * ** * *
** * ** ** *** ** * * * ** * *** ******* *** * *** break;
* ***** * *** **** * *** * * ** * * * *
* ** * ** * ********** * * * * * * ** * i<26; i++){
* * * *** ** * *** * * ** * * ** ** * * ** * *** * ** * * * ** c[i]++;
* ** ** *** * ** *** *** *** * ** * *
* * *** **** *

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

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


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

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

* ** * * **** *

*** * * ** **

* *


* ****

* * ;

*** * * * * ** **
*** = * * *
* *** i, j;

* * * *

{

*

* * * * *

* ** * ***** **

if ** ** ** *

{

********

}

}

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


** ** 0;

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

** * ** ** * ** *

**** * *****

*


*

* * = 0;

* * ** * ***** * * ** ***
* * * * ** i, j;

* * * ***

{

*

** ** ** ****

***** ** ** * *

if ** * *

{

* * * *

}

}

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


* * *

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

#include<string.h>

int main()

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


** ** * * ** ***** * * ** * * ** ***** *
* * * ** * **** i;
* * **** * * * * *** * * * j,k=0;
***** *** ** **** *** * * b[26]= {0};


********* * * *** *** * * * j<strlen(a); j++)

    {
* **** * ** ** * * * ** ** ***** * * *
** * *** * * * * * ******* * * * * * ***** * *** *** i<='z'; i++)
* **** * ** ***** ** **** * * ****** ***
******* *** ***** * * * * ** * ** ****** * * * * * ***


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

    }
**** * ***** ** * ** * * max=0;
**** ** ** * * ** * * * j<26; j++)

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

    }


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

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

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

** ** * * ***

* *


** *****

** len = 0;

** ** * ** * ***** *****
** * i, j;

* ** * *** *

{

* *

* * * * ** ***

* ** ** **** *

if * *** *** *

{

* * * *

}

}

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

* 0;

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

#include<string.h>



int main(void)

{

    char word[100];

    int n[26];
*** * *** * * ** * ** *** **** *** * **

    {
*** *** *** * * *** ****** * * ** *** * l,i,large;
** * * * ******* ***** * * *** ** *
** ** ** *** * ** **** * *** ** ** *** ****** ** data;
** ** * ** *** **** * * ** * * *** * ** * * * ** ** *
* ** * *** *** * ***** *** ****** * ** * * * * *** ** * * *
*** * ** * * * * * * *** *** * * * * *** ***
* *** * ** ** **** ** ** *** * * * *** ** * ***
*** * * **** * **** * *** **** ** * * * * ** * ** * ** *** ** *** *** *****
* * *** ** ** * * * * ** *** * ** ******* * ********** ** ***** * *
* ** **** **** ** * *** ** * ** * ***** *******
** *** **** * * * ** * * * * * * *** ** * *** ** * * *
* * **** *** * **** * ** * ** * ** * * * * * *
* ***** * ***** ** **** * * *** * ** * * **** ** * * ** * * ***** ** * **
** * ** ** * ** *** *** * * * ** * *** * ** * * ** ** ** ** * ******* *
***** ** **** **** * * ** * ** ** * * *** * * *
** ***** ** * * *** ** *** ******** * **** ***** ** * ****



    }

    return 0;

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

*** ** * ** *

* ** * * *** * **

* ** **


* ** **

* len = 0;

* ** * ** **** ****
** * *** ** ** i, j;

* * * * *

{

** *

* **** * * **

* * * * ** *

if ** * ***

{

*** *

}

}

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

* * * 0;

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

#include<ctype.h>

#include<string.h>

int main()

{
* **** *** * * * * * * A[1000], alpha = 'a';
* **** * *** *** * * ** check[26];
* * * ******* ** * **** count[26]={0};
* ** ** * * **** * i=0, j=0, max=-1, remember;


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


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

    {
*** ** ** * **** * ** * **** *** ** * * * * = alpha;
**** ** ** * * **** *** ***** *

    }




* ** * * * *** * * * **** i<strlen(A); i++)
* **** ** * ** *
* * *** *** * * * *** ** * ** **** **** * *
*** *** * ** * *** *** * ** ** * ** ** * *** *
** * * * * *** * *** * * * * ******* ***** * * ** * * ***** ** ** (A[i]==check[j])
******** ** ** ** ** ** ** * *** **** ** * * ****** ** * ** * *** ** ***
* * * ** * * ** ** ** * * ** ** ** * ** * * * *** ** * * * * ** * * ** **
* *** * ******* * * * *** * *** * ** * * ** * * * ****** * * **
* * ** ** * **** * * ** ** * * ** * * * *
* * ** ** *** * ** ***


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

    }
*** ** * ** * ** *** *** * * * * ** count[remember]);


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

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



int main()

{

int a,b,c,i,j ;

int arr[100]={0}, count[27]={0};



for(i=0;i<100;i++)
* ** * * ** *** * **
** * *** *** * *** = getchar();
**** ** ** *** **** ** ***
* * * * * *** * ** ** * * *


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





for(i=0;i<26;i++)
* * *** * * ** *** *
** * * * ** ** * * * * ** * * **
**** *** ** * *** * * * * ** *
* * * ** * ********* ** ** * ****** ** ** * * **** ****** ** **** * * * *
* *** * * **** ** ******* * ** ** ** * * ** ** *** * * * *** *** * ** * * * *** **
* ** ***** *** *** ******** ** **** **
** * *** * * * * *

a = 0 ;

for(i=0;i<26;i++)
* ********* *** * * *
*** *** * * *** * * * ** * ** * ** ** * * ** *
******* *** * * * * * ***** *** * ****** * ** ** **** = count[i];
* * * *** ** * * *

printf("%d",a);





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

Related questions

1 like 0 dislike
58 answers
[Exercise] Coding (C) - asked Mar 23, 2017 in C
ID: 23261 - Available when: Unlimited - Due to: Unlimited
| 1.3k views
0 like 0 dislike
23 answers
[Exercise] Essay (Open question) - asked Mar 23, 2017 in C
ID: 23262 - Available when: Unlimited - Due to: Unlimited
| 792 views
0 like 0 dislike
82 answers
[Exercise] Coding (C) - asked Mar 9, 2017 in C by thopd (12.1k points)
ID: 22674 - Available when: Unlimited - Due to: Unlimited
| 1.4k views
12,783 questions
183,443 answers
172,219 comments
4,824 users