平日小问题 (2):[Error] 'setprecision' is not a member of 'std'

#include 

template 
t sum(t x,t y)
{
    return x+y;
}

int main()
{
    int a,b;
    double c,d;

    std::cin>>a>>b>>c>>d;

    std::cout<(a,b)<<std::endl;
    std::cout<::fixed<::setprecision(3)<std::endl;
}

报错:[Error] ‘setprecision’ is not a member of ‘std’

需要加上头文件 便可通过编译

修改后:

#include 
#include 
template 
t sum(t x,t y)
{
    return x+y;
}

int main()
{
    int a,b;
    double c,d;

    std::cin>>a>>b>>c>>d;

    std::cout<(a,b)<<std::endl;
    std::cout<::fixed<::setprecision(3)<std::endl;
}

你可能感兴趣的:(问题集)