|
|
发表于 2018-12-12 17:45:20
|
显示全部楼层
0.
#include <stdio.h>
#include <math.h>
//0. 问题:求 1^2 + 2^3 + 3^4 + 4^5 + 5^6 的值?(1^2 表示 1 的 2 次方)1+8+
int main()
{
int i = 1;
int j = 2;
double result=0;
// pow(2, 31) - 1
do
{
result+=(pow(i, j));
i++;
j++;
}while (i<=5);
printf("%lf\n", result);
printf("%lf", pow(1, 2)+pow(2, 3)+pow(3, 4)+pow(4, 5)+pow(5,6));
return 0;
}
#include <stdio.h>
#include <math.h>
int main()
{
unsigned long long int temp;
unsigned long long int sun=0;
unsigned long long int weight;
int i;
for(i=0; i<64; i++)
{
temp = pow(2, i);
sun += temp;
}
weight = sun/25000;
printf("舍罕王应该给予达依尔%llu粒麦子!\n", sun);
printf("如果没25000粒麦子为1kg,那么应该给%llu粒麦子!\n", weight);
return 0;
} |
|