请问数据类型课后测试题这两段代码我感觉是一样的但为什么输出结果却不同?
#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("一共有%11u粒麦子\n",sum);
printf("麦子重%11u千克",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;
} printf("一共有%11u粒麦子\n",sum);
printf("麦子重%11u千克",weight);
你这里是 11 吧数字一
迷雾少年 发表于 2019-8-11 15:45
printf("一共有%11u粒麦子\n",sum);
printf("麦子重%11u千克",weight);
哦好像答案上的是字母......顺便再问一句我怎么没查到这个占位符%llu,它是什么意思?C:\Users\29119\Desktop\c\图 我是Pluto 发表于 2019-8-11 16:31
哦好像答案上的是字母......顺便再问一句我怎么没查到这个占位符%llu,它是什么意思?
long long unisigned
https://blog.csdn.net/u010388659/article/details/81475580 感谢大佬的帮助{:10_254:}
页:
[1]