BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / acm-icpc / #98784同步于 2020/2/23
该镜像源已超过 30 天没有更新,可能在源站已被删除。
ACM_ICPC机器人发帖

【交流】想问下学校的oj是不是不支持math.h库

m995877461
2020/2/23镜像同步4 回复
用了abs函数oj报编译错误。。 自己写的abs函数就没问题。。 就这个简单的程序都会报编译错误。。 顺便问下机试的时候支持math.h库吗 #include<stdio.h> #include<math.h> int main() {int a=-1; printf("%d",abs(a)); }
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
whn6325689机器人#1 · 2020/2/26
支持吧? 你选的是语言是GCC么?没有选成C++?
m995877461机器人#2 · 2020/2/26
我改用stdc/c++了.. 【 在 whn6325689 (Mr. Phoebe) 的大作中提到: 】 : 支持吧? : 你选的是语言是GCC么?没有选成C++?
Nroskill机器人#3 · 2020/2/26
试试#include <cmath>
nuanyangyang机器人#4 · 2020/3/28
因为abs不在math.h里,而是在stdlib.h里。 #include <stdlib.h> p.s. 贴个男人页: ABS(3) Linux Programmer's Manual ABS(3) NAME abs, labs, llabs, imaxabs - compute the absolute value of an integer SYNOPSIS #include <stdlib.h> int abs(int j); long int labs(long int j); long long int llabs(long long int j); #include <inttypes.h> intmax_t imaxabs(intmax_t j); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): llabs(): _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L DESCRIPTION The abs() function computes the absolute value of the integer argument j. The labs(), llabs() and imaxabs() functions compute the absolute value of the argument j of the appropriate integer type for the function. RETURN VALUE Returns the absolute value of the integer argument, of the appropriate integer type for the function. ATTRIBUTES For an explanation of the terms used in this section, see attributes(7). ┌──────────────────────────────┬───────────────┬─────────┐ │Interface │ Attribute │ Value │ ├──────────────────────────────┼───────────────┼─────────┤ │abs(), labs(), llabs(), imax‐ │ Thread safety │ MT-Safe │ │abs() │ │ │ └──────────────────────────────┴───────────────┴─────────┘ CONFORMING TO POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD. C89 only includes the abs() and labs() functions; the functions llabs() and imaxabs() were added in C99. NOTES Trying to take the absolute value of the most negative integer is not defined. The llabs() function is included in glibc since version 2.0. The imaxabs() function is included in glibc since version 2.1.1. For llabs() to be declared, it may be necessary to define _ISOC99_SOURCE or _ISOC9X_SOURCE (depending on the version of glibc) before including any standard headers. By default, GCC handles abs(), labs(), and (since GCC 3.0) llabs() and imaxabs() as built-in functions. SEE ALSO cabs(3), ceil(3), fabs(3), floor(3), rint(3) COLOPHON This page is part of release 5.05 of the Linux man-pages project. A description of the project, information about re‐ porting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. GNU 2016-03-15 ABS(3)