Ray's playground

 

POJ 1004

code
 1 #include <iostream>
 2 #include <iomanip>
 3 #include <vector>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     vector<float> items;
 9     int i=0;
10     float f = 0;
11     while(i < 12)
12     {
13         i++;
14         cin >> f;
15         items.push_back(f);
16     }
17 
18     f = 0;
19     for(vector<float>::iterator iterator = items.begin(); iterator != items.end(); iterator++)
20     {
21         f += *iterator;
22     }
23 
24     long a = f * 100 / 12;
25     long p1 = a / 100;
26     long p2 = a % 100;
27     cout << "$" << p1 << "." << p2 << endl;
28 
29 }

 

posted on 2010-08-12 16:08  Ray Z  阅读(189)  评论(0编辑  收藏  举报

导航