Problem Link: 10424 - Love Calculator
/****************##### بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم #####******************
__________________________________________________________________________
###################### Ya-Seen Arafat(ACWizard) #########################
###################### UAP-CSE-33B #########################
*************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int main()
{
char first[30], second[30];
int i,sin1, sin2, neel1, neel2;
float love;
while(gets(first)){
gets(second);
sin1=0;
for(i=0;first[i];i++){
if(first[i] >= 'a' && first[i] <= 'z')
sin1 += (first[i] - 96);
else if(first[i] >= 'A' && first[i] <= 'Z')
sin1 += (first[i] - 64);
}
neel1 = 0;
while(sin1 != 0){
neel1 += sin1 % 10;
sin1 /= 10;
}
if(neel1 > 9){
sin1 = neel1;
neel1 = 0;
while(sin1 != 0){
neel1 += sin1 % 10;
sin1 /= 10;
}
}
sin2 = 0;
for(i=0; second[i]; i++){
if(second[i] >= 'a' && second[i] <= 'z')
sin2 += second[i]-96;
else if(second[i]>='A'&&second[i] <= 'Z')
sin2 += second[i] - 64;
}
neel2 = 0;
while(sin2 != 0){
neel2 += sin2 % 10;
sin2 /= 10;
}
if(neel2 > 9){
sin2 = neel2;
neel2=0;
while(sin2 != 0){
neel2 += sin2 % 10;
sin2 /= 10;
}
}
if(neel1 > neel2)
love = (float)neel2 * 100 / (float)neel1;
else
love= (float)neel1 * 100 / (float)neel2;
printf("%0.2f %%\n",love);
}
return 0;
}
/****************##### بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم #####******************
__________________________________________________________________________
###################### Ya-Seen Arafat(ACWizard) #########################
###################### UAP-CSE-33B #########################
*************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int main()
{
char first[30], second[30];
int i,sin1, sin2, neel1, neel2;
float love;
while(gets(first)){
gets(second);
sin1=0;
for(i=0;first[i];i++){
if(first[i] >= 'a' && first[i] <= 'z')
sin1 += (first[i] - 96);
else if(first[i] >= 'A' && first[i] <= 'Z')
sin1 += (first[i] - 64);
}
neel1 = 0;
while(sin1 != 0){
neel1 += sin1 % 10;
sin1 /= 10;
}
if(neel1 > 9){
sin1 = neel1;
neel1 = 0;
while(sin1 != 0){
neel1 += sin1 % 10;
sin1 /= 10;
}
}
sin2 = 0;
for(i=0; second[i]; i++){
if(second[i] >= 'a' && second[i] <= 'z')
sin2 += second[i]-96;
else if(second[i]>='A'&&second[i] <= 'Z')
sin2 += second[i] - 64;
}
neel2 = 0;
while(sin2 != 0){
neel2 += sin2 % 10;
sin2 /= 10;
}
if(neel2 > 9){
sin2 = neel2;
neel2=0;
while(sin2 != 0){
neel2 += sin2 % 10;
sin2 /= 10;
}
}
if(neel1 > neel2)
love = (float)neel2 * 100 / (float)neel1;
else
love= (float)neel1 * 100 / (float)neel2;
printf("%0.2f %%\n",love);
}
return 0;
}
No comments:
Post a Comment