Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- freopen("in.txt", "r", stdin);
- freopen("out.txt", "w", stdout);
- int tc;
- scanf("%d", &tc);
- int tr;
- for(tr = 1; tr <= tc; tr++){
- double income_per_month = 0.0;
- double income_per_year = 0.0;
- double average_income = 0.0;
- int i;
- for(i = 0; i < 12; i++){
- scanf("%lf", &income_per_month);
- income_per_year += income_per_month;
- }
- average_income = income_per_year / 12.0;
- // double fraction, decimal;
- // fraction = modf(average_income, &decimal);
- // int intpart = decimal;
- double thousand = average_income / 1000;
- if(thousand > 0.0){
- int before_commah = average_income/1000;
- double after_commah = average_income - (before_commah*1000);
- printf("%d $%d,%0.2lf\n", tr, before_commah, after_commah);
- }
- else if(thousand <= 0.0){
- printf("%d $%0.2lf\n", tr, average_income);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement