hdu 4493 卡输入输出
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4493
一个double 如果就用cout 貌似会用科学技术法;
#include<iostream> using namespace std; int x1(double k) { k*=10; return (int)k%10; } int x2(double k) { k*=100; return (int)k%10; } int x3(double k) { k*=1000; return (int)k%10; } int main() { int T; cin>>T; while(T--) { double ans=0; for(int i=0;i<12;i++) { double temp; cin>>temp; ans+=temp; } ans/=12; if(x3(ans)>=5) ans+=0.01; cout<<"$"<<(long long )ans; int a1=x1(ans); int a2=x2(ans); if(a1==0&&a2==0) cout<<endl; else if(a1!=0&&a2==0) cout<<"."<<a1<<endl; else cout<<"."<<a1<<a2<<endl; // cout<<"$"<<ans<<endl; //这样就会错 } }