文章
34
粉丝
329
获赞
1
访问
282.5k
#include <iostream>
using namespace std;
class sum
{public:
int summ(int a)
{int sum1=0;
while(a!=0)
{sum1+=a%10;
a=a/10;
}
return sum1;
}
};
class mul
{public:
int mult(int b)
{int sum2=0;
while(b!=0)
{sum2+=b%10;
b=b/10;
}
return sum2;
}
};
int main()
{sum aa;
mul bb;
int a,sum1,sum2,b,i=4;
while(i--){
cin>>a;
b=a*a;
sum1=aa.summ(a);
sum2=bb.mult(b);
cout<<sum1<<" "<<sum2<<endl;}
return 0;
}
登录后发布评论
暂无评论,来抢沙发