10424 - Love Calculator Solution

Solution in C:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    char male[26],female[26];
    int i,j,sum,val,sum2,m1,n1,m2,n2,val2;
    float love,love2;
    while(gets(female))
    {
        gets(male);
        sum=0;
        for(i=0; i<strlen(female); i++)
        {
            if(female[i]>64&&female[i]<91)
            {
                val=female[i]-64;
                sum=sum+val;
            }
            if(female[i]>96&&female[i]<123)
            {
                val=female[i]-96;
                sum=sum+val;
            }

        }
        while(sum>9)
        {
            n1=sum;
            m1=0;
            while(n1>0)
            {
                m1=m1+n1%10;
                n1=n1/10;
            }
            sum=m1;

        }
        sum2=0;
        for(j=0; j<strlen(male); j++)
        {
            if(male[j]>64&&male[j]<91)
            {
                val2=male[j]-64;
                sum2=sum2+val2;
            }
            if(male[j]>96&&male[j]<123)
            {
                val2=male[j]-96;
                sum2=sum2+val2;
            }

        }
        while(sum2>9)
        {
            n2=sum2;
            m2=0;
            while(n2>0)
            {
                m2=m2+n2%10;
                n2=n2/10;
            }
            sum2=m2;


        }
        if(sum>sum2)
        {
            love=(((float)sum2/sum)*100);
            printf("%.2f %%",love);
        }
        else
        {
            love2=(((float)sum/sum2)*100);
            printf("%.2f %%",love2);
        }

        printf("\n");
    }

}


No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.