10424 - Love Calculator

All about problems in Volume 104. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 10424 - Love Calculator

Post by lighted »

Input

Code: Select all

shanto
saima
Acc Output

Code: Select all

71.43 %
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
jasir
New poster
Posts: 1
Joined: Sat Jan 17, 2015 8:05 am

Re: 10424 - Love Calculator

Post by jasir »

As i know it is old thread but most of people want to know the code for creating a love calculator and i can help. I have created a web calculator in php and js located here and it is based on a new code and according to my users it is showing correct results. If you want to learn then i can help.
shourovfoisal
New poster
Posts: 1
Joined: Sat Nov 22, 2014 8:59 pm

Re: 10424 - Love Calculator

Post by shourovfoisal »

Hi,
My code isn't working for the following critical input given in uDebug:

Code: Select all

HgU
Alld
Running this input in my code, I found the output:

Code: Select all

50.00 %
I know the accepted output is 22.22 % . But is this correct? Calculating the input data manually, I found out the result should be 50.00 %. Though I might be wrong. All the other inputs are working correctly I guess. Please help.

Below is my solution in c++:

Code: Select all

#include<stdio.h>
#include<string.h>

int lc(int n)
{
    if(n>=10)
    {
        int sum=0;
        while(n)
        {
            sum+=(n%10);
            n/=10;
        }
        return lc(sum);
    }
}

int main()
{
    int i,sum1,sum2;
    float res;
    char n1[30],n2[30];
    while(gets(n1))
    {
        gets(n2);
        sum1=sum2=0;
        for(i=0;n1[i]!='\0';i++)
        {
            if(n1[i]>=97&&n1[i]<=122)
                sum1+=(n1[i]-96);
            else if(n1[i]>=65&&n1[i]<=90)
                sum1+=(n1[i]-64);
        }
        for(i=0;n2[i]!='\0';i++)
        {
            if(n2[i]>=97&&n2[i]<=122)
                sum2+=(n2[i]-96);
            else if(n2[i]>=65&&n2[i]<=90)
                sum2+=(n2[i]-64);
        }
        sum1=lc(sum1);
        sum2=lc(sum2);
        if(sum1<sum2)
            res= (float)sum1*100/(float)sum2;
        else
            res= (float)sum2*100/(float)sum1;
        printf("%.2f %%\n",res);
    }
    return 0;
}
Post Reply

Return to “Volume 104 (10400-10499)”