我的C ++代码错误的CodeForces错了什么?

时间:2014-12-10 14:19:00

标签: c++

enter image description here

#include <iostream>
#include<math.h>
using namespace std;

int main()
{
int h1,min1,h2,min2;
cin>>h1>>min1>>h2>>min2;
if(h1==h2 && min1>min2)
    cout<<(24*60)-fabs(min1-min2);
    else if (h1>h2)
        cout<<((fabs((h1-24)+fabs(h2%12))*60))-fabs(min1-min2);
    else if (h2>h1)
        cout<<((h2-h1)*60)-fabs(min1-min2);
}

所有outPut都是正确的,但它在代码强制中说错了我想知道什么是错误的只是CodeForces或者有些东西是unlogic或者Code一般是错的!?

1 个答案:

答案 0 :(得分:0)

Visual Studio说,出了什么问题:

    1>------ Build started: Project: test19, Configuration: Debug Win32 ------
1>  test19.cpp
1>c:\documents\visual studio 2010\projects\test19\test19\test19.cpp(15): error C2668: 'fabs' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(565): could be 'long double fabs(long double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(517): or       'float fabs(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(118): or       'double fabs(double)'
1>          while trying to match the argument list '(int)'
1>c:\documents\visual studio 2010\projects\test19\test19\test19.cpp(17): error C2668: 'fabs' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(565): could be 'long double fabs(long double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(517): or       'float fabs(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(118): or       'double fabs(double)'
1>          while trying to match the argument list '(int)'
1>c:\documents\visual studio 2010\projects\test19\test19\test19.cpp(17): error C2668: 'fabs' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(565): could be 'long double fabs(long double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(517): or       'float fabs(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(118): or       'double fabs(double)'
1>          while trying to match the argument list '(int)'
1>c:\documents\visual studio 2010\projects\test19\test19\test19.cpp(19): error C2668: 'fabs' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(565): could be 'long double fabs(long double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(517): or       'float fabs(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(118): or       'double fabs(double)'
1>          while trying to match the argument list '(int)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========