代码如下:
#includeusing namespace std;int main() { int m, n, i, sum1, sum2, temp; while (cin >> m >> n) { sum1 = 0; sum2 = 0; if (m > n) { //没有考虑到假如第一个整数比第二个整数小的情况 temp = m; m = n; n = temp; } for (i = m; i <= n; i++) { if (i % 2 == 0) { sum1 = sum1 + i*i; } else { sum2 = sum2 + i*i*i; } } cout << sum1 << " " << sum2 << endl; } return 0;}