sun186333 @ 2024-12-21 16:02:00
#include<stdio.h>
int main()
{double x;
scanf("%lf",&x);
printf("%d",(int)x);
return 0;
}
为什么讨论区都在说用long long啊?那不是长整型吗?题目不是双精度浮点型吗?求大佬解答^~^
by _Xiaoyao_ @ 2024-12-21 16:22:13
@sun186333
long double
by huchenlin0127 @ 2024-12-21 16:26:53
数据类型 用longlong
by sun186333 @ 2024-12-21 17:12:07
@huchenlin0127 为什么啊?long long不是长整型吗?题目要求的不是双精度浮点型吗?而且我用long long试了,也不行/(ㄒoㄒ)/~~
by sun186333 @ 2024-12-21 17:14:50
@Xiaoyao 我刚用long double试了,也不行啊/(ㄒoㄒ)/~~
by huchenlin0127 @ 2024-12-23 13:00:31
cout<<(long long)x; 代码如上
by ChuanBoy_tlp @ 2025-01-10 09:40:33
@sun186333 就是double转成int溢出了,所以输出要转成long long