为什么加上cstdlib才能用ans啊?

P1067 [NOIP2009 普及组] 多项式输出

emmmm……我怎么没听过这个函数……
by Error_502 @ 2018-08-14 16:00:48


@[Gekoo](/space/show?uid=107961) 那个函数叫 abs,虽然键盘上 b 和 n 挨得很近,但您不能叫它 ans 啊
by Anguei @ 2018-08-14 16:02:14


@[yyfcpp](/space/show?uid=53062) 打错了Orz
by ikitsu @ 2018-08-14 16:03:41


voc!原来是`abs()`!
by Error_502 @ 2018-08-14 16:07:16


@[Gekoo](/space/show?uid=107961) abs在cmath的定义是 ``` inline double abs(double __x) { return __builtin_fabs(__x); } inline float abs(float __x) { return __builtin_fabsf(__x); } inline long double abs(long double __x) { return __builtin_fabsl(__x); } ``` 在cstdlib的定义是 ``` inline long abs(long __i) { return labs(__i); } ``` 所以abs对于整型的声明是在cstdlib里,对于浮点数的声明在cmath里 我太菜了,也借这楼问问各大佬这个对不对?
by namespace_std @ 2018-08-14 16:22:17


@[namespace_std](/space/show?uid=85053) 我现在知道了,C++17里的cmath才有abs(),,,
by ikitsu @ 2018-08-14 16:23:22


@[Gekoo](/space/show?uid=107961) 不对吧?我的C-Free 5用的还是GNU 98标准,然而在cmath里是能找到上面的描述的
by namespace_std @ 2018-08-14 16:26:41


![luogu](https://cdn.luogu.com.cn/upload/pic/28561.png)
by namespace_std @ 2018-08-14 16:28:14


![](https://i.loli.net/2018/08/14/5b729321b43c0.png)cppreference上是这么写的
by ikitsu @ 2018-08-14 16:32:13


以后abs还是自己写吧Orz
by ikitsu @ 2018-08-14 16:34:31


| 下一页