#include #include #define STR_LENGTH 16 #define NUM_INPUT 4 void str_cut(char*, unsigned char*); int main(void){ unsigned char diff = 0; unsigned char same = 0; char str[STR_LENGTH]; unsigned char input[NUM_INPUT] = {0}; unsigned int ans = 0; fgets(str, sizeof(str), stdin); str_cut(str, input); if((input[3] < input[0]) || (input[1] < input[2])) { ans = (input[1] - input[0] + 1) * (input[3] - input[2] + 1); } else { diff = abs(input[2] - input[0]) + abs(input[3] - input[1]); same = ((input[1] - input[0] + 1) + (input[3] - input[2] + 1 - diff)) / 2; ans = (input[1] - input[0] + 1) * (input[3] - input[2] + 1) - same; } printf("%d\n", ans); return 0; } /* 関数概要:渡された文字列を空白で分離し、数値に変換する 第1引数:文字列 第2引数:文字列から数値に変換して格納する配列 */ void str_cut(char* str, unsigned char* input){ int start_str = 0; int num = 0; //配列NO int i = 0; while('\0' != str[i]){ if(' ' == str[i]){ str[i] = '\0'; input[num] = (unsigned char) atoi(&str[start_str]); ++num; ++i; start_str = i; } ++i; } input[num] = (unsigned char) atoi(&str[start_str]); return; }