注意:在if(condition)中,只要condition不为0,就是真,也是就是说,如果为负数也为真
#include <iostream>
using namespace std;
int main ()
{
int n;
cin >> n;
int x, y;
while (n -- )
{
cin >> x >> y;
if(x > y) swap(x, y);
long long sum = 0;
for (int i = x + 1; i < y; i ++ )
{
if (i % 2 ) sum += i;
}
cout << sum << endl;
}
return 0;
}