数据类型课后作业求助
#include<stdio.h>#include<math.h>
int main()
{ unsigned long longsum=0;
unsigned long longweight;
unsigned long longtemp;
int i;
for(i=0; i<64; i++)
{
temp=pow(2,i);
sum=sum+temp;
}
weight=sum/25000;
printf("麦子总粒数%11u\n",sum);
printf("麦子总重%11u\n",weight);
return 0;
}
数据类型那一张作业,为什么结果和小甲鱼的不一样,有没有大佬看看 下面是小甲鱼的答案
#include <stdio.h>
#include <math.h>
int main()
{
unsigned long long sum = 0;
unsigned long long temp;
unsigned long long weight;
int i;
for (i=0; i < 64; i++)
{
temp = pow(2, i);
sum = sum + temp;
}
weight = sum / 25000;
printf("舍罕王应该给予达依尔%llu粒麦子!\n", sum);
printf("如果每25000粒麦子为1kg,那么应该给%llu公斤麦子!\n", weight);
return 0;
} %llu里面的l应该是英文字母l,不是数字1,
llu指的是long long unsigned isdkz 发表于 2022-2-11 19:00
%llu里面的l应该是英文字母l,不是数字1,
llu指的是long long unsigned
奥好的,太感谢了
页:
[1]