|
|
发表于 2019-11-24 13:37:48
|
显示全部楼层
0.
//不用循环
#include <stdio.h>
int main()
{
int cal1 = pow(1, 2) + pow(2, 3) + pow(3, 4) + pow(4, 5) + pow(5, 6);
printf("%d\n", cal1);
return 0;
}
//用循环
#include <stdio.h>
int ter;
int cal2;
int n;
int main()
{
for (n = 1; n < 6; n++)
{
ter = pow(n, (n + 1));
cal2 = cal2 + ter;
}
printf("%d\n", cal2);
return 0;
}
1.
#include <stdio.h>
#include <math.h>
int main()
{
double sum;
double temp;
double weight;
int i;
for (i = 0; i < 64; i++)
{
temp = pow(2, i);
sum = sum + temp;
}
weight = sum / 25000;
printf("%.f粒麦子!\n", sum);
printf("25000粒麦子为1kg,那么应该给%.f公斤麦子!\n", weight);
return 0;
} |
|