• 第一次看全英文的题,还是有点不舒服的感觉,还是用了翻译器

    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.

    Input

    The input 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.

    Output

    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

    Sample Input

    100.00

    489.12

    12454.12

    1234.10

    823.05

    109.20

    5.27

    1542.25

    839.18

    83.99

    1295.01

    1.75

    Sample Output

    $1581.42

代码样例:

#include<stdio.h>

#define N 12

int main()

{

double m=0,l;

double s[N];

int i;

for(i=0;i<N;i++)

{scanf("%lf\n",&s[i]);        

m=m+s[i];}

l=m/N;

printf("$");

printf("%.2lf",l);

return 0;

}
  • 定义一个可以存放十二个数值的数组,循环累加,计算平均

数组练习题A财务管理的更多相关文章

  1. Java数组练习题小结

    //2015/07/07 //Java数组小小练习题 /* 3. 写一个函数,计算一个整数数组的平均值 4. 自定义一个整数数组a,读入一个整数n,如果n 在数组中存在,则输出n 的下标:如果不存在, ...

  2. Java循环和数组练习题:打印素数升级版

    前两天一个小伙伴问了我一个数组的练习题,我一看思路很清晰,就是打印素数加了个数组.没想到写的时候啪啪打脸,终究还是没逃过眼高手低.本来不打算发出来了,因为发出来愈发显得我很菜,最后还是打算分享出来,一 ...

  3. Java学习笔记6(循环和数组练习题)

    1.输出100到1000的水仙花数: public class LoopTest{ public static void main(String[] args){ int bai = 0; int s ...

  4. 【图文+视频新手也友好】Java一维数组详细讲解(内含练习题答案+详解彩蛋喔~)

    目录 视频讲解: 一.数组的概述 二.一维数组的使用 三.Arrays工具类中的sort方法(sort方法用的多,我们具体讲一下) 四.数组中的常见异常 五.一维数组练习题 六.彩蛋(本期视频使用的P ...

  5. NSArray数组的学习总结

    1.不可变数组NSArray NSArray是不可变的,而且只能储存Object-c对象.另外,数组的最后一个元素一定是nil,表示结束. 注:这些集合类只能收集cocoa对象(NSOjbect对象) ...

  6. awk巩固练习题

    第1章 awk数组练习题 1.1 文件内容(仅第一行) [root@znix test]# head -1 secure-20161219 access.log ==> secure-20161 ...

  7. Ping pong(树状数组求序列中比某个位置上的数小的数字个数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2492 Ping pong Time Limit: 2000/1000 MS (Java/Others) ...

  8. day04_数组

    数组 学习目标: 1. jvm内存图入门 2. 一维数组的使用 3. 二维数组的使用 4. 数组的内存结构 5. 数组中常见算法 6. 数组中常见的异常 一.JVM内存图入门 java程序运行在jvm ...

  9. awk高级进阶

    第1章 awk数组练习题 1.1 文件内容(仅第一行) [root@znix test]# head -1 secure-20161219 access.log ==> secure-20161 ...

随机推荐

  1. python第五天,两个知识点三目运算符和assert抛异常处理。

    在python 2.5x之前是没有三目运算符的,但随着语言的发展,在2.5之后就加入了三目运算符 ''' 这里主要将三目运算符 其中也可以通过 x,y=4,5这种方式进行快速的声明变量和对变量赋值. ...

  2. 配置Oracle GoldenGate安全性

    本章介绍如何配置Oracle GoldenGate安全性. 本章包括以下部分: Overview of Oracle GoldenGate Security Options Encrypting Da ...

  3. nginx使用https协议

    效果: nginx添加ssl模块 ./configure --with-http_ssl_module 生成证书 openssl genrsa -out ca.key 2048 openssl req ...

  4. qtcreator 快捷键常用

    F1        查看帮助F2        跳转到函数定义(和Ctrl+鼠标左键一样的效果)Shift+F2    声明和定义之间切换F4        头文件和源文件之间切换Ctrl+1     ...

  5. python set 使用

    创建集合set python set类是在python的sets模块中,大家现在使用的python2.7.x中,不需要导入sets模块可以直接创建集合.>>>set('boy')se ...

  6. SSH远程联机Linux服务器简易安全设定

    分别可以由底下这三方面来进行: 1.服务器软件本身的设定强化:/etc/ssh/sshd_config 2.TCP wrapper 的使用:/etc/hosts.allow, /etc/hosts.d ...

  7. 【转】C++ 11 并发指南一(C++ 11 多线程初探)

    引言 C++ 11自2011年发布以来已经快两年了,之前一直没怎么关注,直到最近几个月才看了一些C++ 11的新特性,算是记录一下自己学到的东西吧,和大家共勉. 相信Linux程序员都用过Pthrea ...

  8. c++ 值转换

    1.double,float 四舍五入,保留小数位数. void MainWindow::on_pushButton_clicked() { double number=3.141592; ); qD ...

  9. 使用OneNote2016发送博客

    本人使用的是博客园的博客,其他的博客设置应该大同小异,OneNote使用的是2016版本,系统为Win10家庭中文版. 传统的在web端编辑发布博客的方式是在是心累,图文编辑麻烦,不便于存储,编辑的时 ...

  10. git pull/fectch

    git remote: show all remote repositories git push -u <X1> <>: set x1 as the default repo ...