C语言题目 帮帮我啊

来源:百度知道 编辑:UC知道 时间:2024/05/23 20:13:38
编写一个程序,从键盘输入X,Y,Z3个数,编写函数计算3个数的立方和并返回计算结果:S=X3+Y3+Z3 (公式中的3代表立方都是在X Y Z 的右上方的)

#include <stdio.h>

double cubic_sum(double a,double b,double c)
{
return a*a*a+b*b*b+c*c*c;
}

main()
{
double x,y,z;
scanf("%lf%lf%lf",&x,&y,&z);
printf("%lf\n",cubic_sum(x,y,z));
}

#include<stdio.h>
main()
{
int x,y,z,sum;
printf("shu ru san ge shu:\n");
scanf("%d,%d,%d",&x,&y,&z);
sum=x*x*x+y*y*y+z*z*z;
if(sum==x*100+y*10+z*1)
printf("yes!\n");
else
printf("no!\n");
}
此类数为水仙花数,比如说153=1的立方+5的立方+3的立方。