吐了

P2433 【深基1-2】小学数学 N 合一

何奕锐 @ 2021-07-26 13:47:19

这题的cout对非c++语言太不友好了吧

错了三个点6 8 11都是因为cout小数精度问题


by 我送送送送 @ 2021-07-26 13:58:04

可以用printf或者直接把答案算出来再用cout


by 青烟醉西风 @ 2021-08-06 15:04:09

?什么意思? cout 也是可以保留小数的 如:cout << setw(5) << a;//输出a并且保留5位小数


by 王紫烨 @ 2021-08-08 22:10:46

setw是右对齐吧……C++要保留位数应该是

cout<<fixed<<setprecision(小数点后位数)<<a<<endl;

by yuzhile @ 2021-08-15 22:32:44

#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
double b=500.0/3,p=3.141593;
char a=82;
int T,r=5; 
int main() 
{
    cin>>T;
    if (T == 1) cout<<"I love Luogu!";
    if (T == 2) cout<<2+4<<" "<<10-2-4;
    if (T == 3) cout<<14/4<<"\n"<<14-(14%4)<<"\n"<<14%4;
    if (T == 4) cout<<b;
    if (T == 5) cout<<(260+220)/(12+20);
    if (T == 6) cout<<sqrt(6*6+9*9);
    if (T == 7) cout<<"110"<<"\n"<<"90"<<"\n"<<"0";
    if (T == 8) cout<<r*2*p<<"\n"<<p*r*r<<"\n"<<4.0/3*p*r*r*r; 
    if (T == 9) cout<<(((((1+1)*2)+1)*2)+1)*2;
    if (T == 10) cout<<"9";
    if (T == 11) cout<<100.0/(8-5); 
    if (T == 12) cout<<"13"<<"\n"<<a;
    if (T == 13) cout<<(int)pow(4.0/3*4*4*4*p+4.0/3*10*10*10*p,1.0/3);
    if (T == 14) cout<<"50";
    return 0;
}

by jhlryb @ 2021-10-29 21:58:46

**~~ _

_ ~~**这个第八题的思路有点不懂代码显示错误


|