10424 Love Calculator
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a,b;
while(getline(cin,a))
{
getline(cin,b);
float rat;
long s1=0,s2=0;
for(int i=0;i<a.length();i++)
{
char t=tolower(a[i]);
//cout<<t;
if(t>='a'&&t<='z')
{
s1+=t-'a'+1;
}
}
if(s1%9==0) s1=9;
else s1%=9;
for(int i=0;i<b.length();i++)
{
char t=tolower(b[i]);
//cout<<t;
if(t>='a'&&t<='z')
{
s2+=t-'a'+1;
}
}
if(s2%9==0) s2=9;
else s2%=9;
if(s1>s2)
rat=((float)s2/s1)*100.0;
else
rat=((float)s1/s2)*100;
printf("%.2lf %c\n",rat,'%');
}
return 0;
}
0 comments :
Post a Comment