平方和与立方和.c 229 B

123456789101112131415161718
  1. #include <stdio.h>
  2. int main() {
  3. int m,n;
  4. scanf("%d %d",&m,&n);
  5. int square = 0,cube = 0;
  6. while(m <= n) {
  7. if(m % 2 == 0) square += m * m;
  8. else cube += m * m * m;
  9. m++;
  10. }
  11. printf("%d %d",square,cube);
  12. return 0;
  13. }