#include <stdio.h> int main() { int a = 0; scanf("%d",&a); // 当输入为偶数时,(1-2)+ (3 -4) = -1-1 = -1 *(4/2), 则n为偶数时 -1 * (n / 2) // 当输入n为奇数时, 1 - 2 + 3 - 4 + 5 = -1 * ( 4 / 2) + 5 则n为奇数时, n - (n / 2) printf ("%d\n", a % 2 == 0 ? -1 * ( a / 2) : a - (a / 2)); return 0; }