标签:
#include"stdio.h" #include "math.h" int main(void){ int num1, num2; long ESsum=0, OCsum=0; //ESsum偶数平方和,OCsum奇数立方和 while(scanf("%d%d", &num1, &num2) != EOF){ if(num1 <= num2){ while(num1 <= num2){ if(num1 % 2 == 0) //偶数 ESsum += pow(num1, 2); else OCsum += pow(num1, 3); num1++; } printf("%d %d\n", ESsum, OCsum); } else{ while(num2 <= num1){ if(num2 % 2 == 0) //偶数 ESsum += pow(num2, 2); else OCsum += pow(num2, 3); num2++; } printf("%d %d\n", ESsum, OCsum); } ESsum = 0, OCsum = 0; } return 0; }
标签:
原文地址:http://www.cnblogs.com/cnfanhua/p/4220927.html