Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- void converttolower(char s[]){
- for(int i=0; i<strlen(s); i++){
- if(s[i] <=90 && s[i] >= 65){
- s[i] += 32;
- }
- }
- }
- int main(){
- int n;
- char s[100000];
- scanf("%d",&n);
- char ch;
- scanf("%c",&ch);
- while(n--){
- int count[1000];
- int maxasci[1000];
- for(int i=0; i<1000;i++){
- count[i] = 0;
- maxasci[i] = 0;
- }
- fgets(s,1000,stdin);
- int len = strlen(s);
- s[len-1] = 0;
- len = strlen(s);
- converttolower(s);
- for(int i=0; i<len; i++){
- if(s[i] != ' ')
- count[s[i]]++;
- }
- int max = 0;
- int ind =0;
- for(int i=0;i<len; i++){
- if( count[s[i]] > max){
- max = count[s[i]];
- }
- }
- for(int i=0; i<len; i++){
- if(count[s[i]] == max){
- maxasci[s[i]] = s[i];
- }
- }
- for(int i=1; i<=128; i++){
- if(i == maxasci[i]){
- printf("%c",maxasci[i]);
- }
- } printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement