首页 > 试题广场 >

Financial Management

[编程题]Financial Management
  • 热度指数:2893 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    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.

输入描述:
    Each case will be twelve lines. Each line will contain the closing balance of his bank account for a particular month. Each number will be positive and displayed to the penny. No dollar sign will be included.


输出描述:
    For each case, the output will be a single number, the average (mean) of the closing balances for the twelve months. It will be rounded to the nearest penny, preceded immediately by a dollar sign, and followed by the end-of-line. There will be no other spaces or characters in the output.
示例1

输入

100.00
489.12
12454.12
1234.10
823.05
109.20
5.27
1542.25
839.18
83.99
1295.01
1.75

输出

$1581.42
头像 牛客440904392号
发表于 2024-10-02 10:58:48
#Python版代码 print('$%.2f' % (sum((eval(input())) for _ in range(12)) / 12)) #或者 from statistics import mean print('$%.2f' % mean((eval(input())) for _ 展开全文
头像 mrvoider
发表于 2021-03-10 17:45:52
一、题目概述 这道题目意外的简单,说白了,就是将输入的12个数求平均值,再将平均值输出即可。 二、代码实现 #include <bits/stdc++.h> using namespace std; int main() { double input = 0.00; 展开全文
头像 用户抉择
发表于 2021-03-07 12:01:53
#include <stdio.h> int main() {     double a[12],sum=0;     for(int i=0;i<12;i++) 展开全文
头像 粉詹眉
发表于 2024-02-16 17:22:04
#include <iostream> using namespace std; int main() { double a[12]; for(int i=0;i<12;i++) cin>>a[i]; double sum=0; fo 展开全文
头像 chong_0428
发表于 2024-03-21 22:40:51
while True: try: a = [] for i in range(12): n = float(input()) a.append(n) s = sum(a) #pri 展开全文
头像 小路绫ayaya
发表于 2026-03-04 13:11:07
#include <iostream> #include <vector> #include <iomanip> using namespace std; int main() { ios_base::sync_with_stdio(false); 展开全文
头像 lyw菌
发表于 2023-03-10 15:37:15
//测试用例有个错的,没有进位,应该是59.10才对 #include "stdio.h" int main(){ double array[12]; while (scanf("%lf",&array[0])!=EOF){ double sum = array[0 展开全文