ZOJ - 1048
Description Larry graduated this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first step is to figure out what's been going on with his money. Larry has his bank account statements and wants to see how much money he has. Help Larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.
Sample Input:
Source
Mid-Atlantic USA 2001
|
分析:
题目大意:给出12个月的收入,求一个平均值。
解法:没什么好说的,就是一个除法。
代码:
#include<stdio.h> int main(){ int i; float sum=0,k; for(i=0;i<12;i++){ scanf("%f",&k); sum+=k; } sum=sum/12; printf("$%.2f",sum); return 0; }