杭电2007

 1 #include <iostream>

 2 using namespace std;

 3 

 4 int ji(int);

 5 int ou(int);

 6 int main()

 7 {

 8     int m,n,x,y;

 9     while (cin >> m >> n)

10     {

11         if (m>n)

12         {

13             int temp;

14             temp = n;

15             n = m;

16             m = temp;

17         }

18         x=y=0;

19         for (int i=m; i <= n; i++)

20         {

21             (i%2 == 0)?(x += ou(i)):(y += ji(i));

22         }

23         cout << x <<' '<<y <<endl;

24     }

25     return 0;

26 }

27 

28 int ji(int n)

29 {

30     return n*n*n;

31 }

32 int ou(int n)

33 {

34     return n*n;

35 }

此题要判断大小;

你可能感兴趣的:(2007)