---
# System prepended metadata

title: 13601 - Ultimate caesar salad
tags: [ASCII]

---

# 13601 - Ultimate caesar salad

>author: Utin
###### tags: `ASCII`

---

## Brief
See the code below

## Solution 0

```c=
#include <stdio.h>

//Hint: 注意char的範圍

int is_lower(int c);
int is_upper(int c);
int both_upper(int a, int b);
int both_lower(int a, int b);
int upper_correct(int c);
int lower_correct(int c);

int main() {
    int ans;
    char a[6], b[6], c[6];
	
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
	
    for(int i = 0; i < 5; i ++) {
        if(both_upper(a[i], b[i]) || both_lower(a[i], b[i])) {
            ans = c[i] + b[i] - a[i];
            if(is_lower(c[i])) ans = lower_correct(ans);
            else ans = upper_correct(ans);
            printf("%c", ans);
        }
        else {
            if(is_lower(a[i])) ans = c[i] + (b[i] + 32) - a[i];
            else ans = c[i] + (b[i] - 32) - a[i];
            if(is_lower(c[i])) ans = upper_correct(ans-32);
            else ans = lower_correct(ans+32);
            printf("%c", ans);
        }
    }
    printf("\n");
}

int is_lower(int c) {
    return c >= 'a' && c <= 'z';
}

int is_upper(int c) {
    return c >= 'A' && c <= 'Z';
}

int both_upper(int a, int b) {
    return is_upper(a) && is_upper(b);
}

int both_lower(int a, int b) {
    return is_lower(a) && is_lower(b);
}

int upper_correct(int c) {
    if(c > 'Z') return c - 26;
    else if(c < 'A') return c + 26;
    else return c;
}

int lower_correct(int c) {
    if(c > 'z') return c - 26;
    else if(c < 'a') return c + 26;
    else return c;
}
// By Utin
```

## Reference