平方和与立方和 题解:
#include<iostream>
using namespace std;
int main(){
int m,n;
while(cin>>m>>n){
int sumji = 0;
int sumou = 0;
int a = m<n? m:n;
int b = m>n? m:n;
for(int i = a; i<=b; i++){
if(i % 2 == 0){
sumou+=i*i;
}else{
sumji+=i*i*i;
}
}
cout<<sumou<<" "<<sumji<<endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发