北大ACM(POJ1004-Financial Management)

Question:http://poj.org/problem?id=1004
问题点:求平均值及格式化输出。
 1 Memory: 248K        Time: 0MS
 2 Language: C++        Result: Accepted
 3 
 4 #include<iostream>  
 5 #include<iomanip>  
 6 using namespace std;  
 7   
 8 int main(void)  
 9 {  
10     double sum=0.0;  
11     for(int i=1;i<=12;i++)  
12     {  
13         double temp;  
14         cin>>temp;  
15         sum+=temp;  
16     }  
17     cout<<fixed<<setprecision(2)<<'$'<<sum/12.0<<endl;  
18     return 0;  
19 }

 

posted @ 2016-01-07 19:59  月生丶  阅读(212)  评论(0编辑  收藏  举报