Daffodil International University
Problem Link
//Please follow from main function
#include<stdio.h>
#include<string.h>
int digit(int k){
int j, sum=0;
while(k!=0){
j=k%10;
sum+=j;
k/=10;
}
return sum;
}
int main()
{
char f_name[26], l_name[26];
int len1, len2, sum, sum1, i, j;
double percentage, percentage1;
while(scanf("%s %s", f_name, l_name)!=EOF){
sum=0, sum1=0;
len1=strlen(f_name);
len2=strlen(l_name);
for(i=0; i<len1; i++){
if(f_name[i]>='a' && f_name[i]<='z'){
sum+=f_name[i]-96;
}
else if(f_name[i]>='A' && f_name[i]<='Z'){
sum+=f_name[i]-64;
}
}
for(i=0; i<len2; i++){
if(l_name[i]>='a' && l_name[i]<='z'){
sum1+=l_name[i]-96;
}
else if(l_name[i]>='A' && l_name[i]<='Z'){
sum1+=l_name[i]-64;
}
}
percentage=((double)len1/(double)digit(sum))*100.00;
percentage1=((double)len2/(double)digit(sum1))*100.00;
if(percentage>percentage1){
printf("%0.2lf\n", percentage);
}else{
printf("%0.2lf\n", percentage1);
}
}
return 0;
}
0 Comments