题意:
思路:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int fa[150]; int fin(int x) { return fa[x]==x?x:fin(fa[x]); } void unionn(int x,int y) { int fx=fin(x); int fy=fin(y); if(fx!=fy) { fa[fy]=fx; } } int main() { int n,m,t; int i,j,k; double a,sum,now,num[15]; scanf("%d",&t); while(t--) { sum=0; for(i=0;i<12;i++) { scanf("%lf",&now); sum+=now; } sum/=12; sum*=1000; int ans=sum+5; ans/=10; double a; printf("$"); if(ans%10!=0) { a=ans*1.0; printf("%.2f ",a/100); } else if(ans%100!=0) { a=ans*1.0; printf("%.1f ",a/100); } else { printf("%d ",ans/100); } } return 0; }