Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define endl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(), x.end()
- int sum_of_digits(int x) {
- int sum = 0;
- while (x > 0) sum += x % 10, x /= 10;
- return sum;
- }
- int calc(char *s, int n) {
- int sum = 0;
- for (int i = 0; i < n; i++) {
- if (isalpha(s[i])) sum += tolower(s[i]) - 'a' + 1;
- }
- while (sum > 9) sum = sum_of_digits(sum);
- return sum;
- }
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- char name1[30], name2[30];
- while (scanf("%[^\n]%*c%[^\n]%*c", name1, name2) != EOF) {
- int c1 = calc(name1, strlen(name1)), c2 = calc(name2, strlen(name2));
- if (c1 > c2) swap(c1, c2);
- printf("%.2f %%\n", 100.0 * c1 / c2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement