1. cout的setprecision头文件:#include<iomanip>
cout<<setprecision(1)<<fixed<<"T "<<num1<<" D "<<num2<<" H "<<calc_h(num1,num2)<<endl;
2. printf打印double,用%f,printf("%.2f",num1);
scanf输入double,用%lf,scanf("%lf",&num1);
3. cin,cout因为同步会比scanf,printf慢
解决方式,在main函数里加上
ios::sync_with_stdio(false);
4. cout打印数字固定宽度
cout<<setw(20)<<table[j].x<<" "<<setw(20)<<table[j].y<<" "<<setw(20)<<table[j].z<<" "<<table[j].i<<endl;