Advertisement
Eather

11945 - Financial Management

Apr 4th, 2011
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1.                            /*in the name of Allah */
  2.  
  3.  
  4. # include <list>
  5. # include <deque>
  6. # include <bitset>
  7. # include <algorithm>
  8. # include <functional>
  9. # include <numeric>
  10. # include <utility>
  11. # include <sstream>
  12. # include <iostream>
  13. # include <iomanip>
  14. # include <cstdio>
  15. # include <cmath>
  16. # include <cstdlib>
  17. # include <ctime>
  18. # include <set>
  19. # include <map>
  20. # include <cmath>
  21. # include <queue>
  22. # include <limits>
  23. # include <stack>
  24. # include <vector>
  25. # include <cstring>
  26. # include <cstdio>
  27. using namespace std;
  28.  
  29. # define MEM(array,w)   memset(array,w,sizeof array)
  30. # define fr(i,a,b) for(int (i) = a ; i < b ; i++)
  31. # define SET set<int>::iterator it = s.begin(); it != s.end();it++
  32. # define ULL unsigned long long
  33. # define eps 1e-9
  34. # define SS stringstream
  35. # define PR pair<int , int>
  36. # define all(c) (c).begin(), (c).end()
  37. # define maxint 1 << 31 - 1
  38. # define FOR(i, a, b) for (int i=a; i<b; i++)
  39. # define REP(i, a) FOR(i, 0, a)
  40. # define rive(s) reverse(s.begin(),s.end())
  41. # define OK(R,C) if(i>=0 && j>=0 && j<=C && i<=R)
  42.  
  43. template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}
  44.  
  45. int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
  46.  
  47. bool isprime(int n){if( n<2) return 0;for( int i=2; i*i<=n ; i++)if(n%i==0)return 0; return 1;return 0;}
  48.  
  49. int pel(string s){string t;t=s;reverse(t.begin(),t.end());if(s==t)return 1;return 0;}
  50.  
  51.  
  52. int main()
  53. {
  54.  
  55.  
  56.   int n;
  57.   cin>>n;
  58.   int caset=0;
  59.   while(n--)
  60.   {
  61.     long double sum=0.;
  62.     for(int i=0;i<12;i++)
  63.     {
  64.       long double inp;
  65.       cin>>inp;
  66.       sum+=inp;
  67.     }
  68.     sum/=12;
  69.  
  70.     string s= toString(sum);
  71.  
  72.     string res="";
  73.  
  74.     rive(s);
  75.  
  76.     for(int i=0;i<s.size();i++)
  77.     {
  78.       res+=s[i];
  79.     if(i>4 && i%3==2 && i!=s.size()-1)res+=",";
  80.     }
  81.     rive(res);
  82.  
  83.     printf("%d $",++caset);cout<<res<<endl;
  84. }
  85. return 0;
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement