¶
~cpp
//LoveCalculator
#include <stdio.h>
#include <string.h>
void get_names(char *first_person, char *second_person);
void calculator(char *first_person, char *second_person);
int sum_name(char name[25]);
void main()
{
char first_person[30];
char second_person[30];
char ch;
while((ch = getchar()) != EOF)
{
ungetc(ch, stdin);
get_names(first_person, second_person);
calculator(first_person, second_person);
}
}
void get_names(char *first_person, char *second_person)
{
gets(first_person);
gets(second_person);
if(strlen(first_person) > 25 || strlen(second_person) > 25)
{
get_names(first_person, second_person);
}
}
void calculator(char *first_person, char *second_person)
{
int first_person_sum, second_person_sum;
float percentage;
first_person_sum = sum_name(first_person);
second_person_sum = sum_name(second_person);
while(first_person_sum >= 10)
{
first_person_sum = (first_person_sum % 10) + (first_person_sum % 100) / 10 + (first_person_sum / 100);
// 한 ..
}
while(second_person_sum >= 10)
{
second_person_sum = (second_person_sum % 10) + (second_person_sum % 100) / 10 + (first_person_sum / 100);
}
if(first_person_sum < second_person_sum)
{
percentage = (float)first_person_sum/second_person_sum;
}else{
percentage = (float)second_person_sum/first_person_sum;
}
percentage *= 100;
// result print
printf("%.2f", percentage);
printf(" %% \n");
}
int sum_name(char name[25])
{
int sum = 0, i = 0;
while(name[i] > 0)
{
if(name[i] >= 65 && name[i] <= 90)
{
sum = sum + name[i] - 64;
}else if(name[i] >= 97 && name[i] <= 122)
{
sum = sum + name[i] - 96;
}else{}
++i;
}
return sum;
}
한테 할 ¶
히 Girl~ㅎ ~ 한 ..ㅎ
한 ?ㅎ ??( 하.ㅎ)
.. 한 .ㅎ( !!킁..ㅠ.ㅜ)
.. 할 ~ㅎ
.. 1 2 .. 하 할 ..ㅎ
하~ㅎ 하..ㅎ 한 ..ㅠ.ㅜㅎ - 태
tolower(해 , )함 toupper() 파 (alpha = alpha - 'a' +1) 하 할 , 한 ? - 호
크크 toupper ... 'a' ... ㅠㅠ
함 .
; ; -;;; 흑 ㅠㅠ
gets 함 ㅠㅠ - zyint
----
한 ?ㅎ ??( 하.ㅎ)
.. 한 .ㅎ( !!킁..ㅠ.ㅜ)
.. 할 ~ㅎ
.. 1 2 .. 하 할 ..ㅎ
하~ㅎ 하..ㅎ 한 ..ㅠ.ㅜㅎ - 태
. 한 ㅋㅋ
tolower(해 , )함 toupper() 파 (alpha = alpha - 'a' +1) 하 할 , 한 ? - 호
- . 함 .
크크 toupper ... 'a' ... ㅠㅠ
함 .
; ; -;;; 흑 ㅠㅠ
gets 함 ㅠㅠ - zyint
LittleAOI LoveCalculator










