数组练习题A财务管理
第一次看全英文的题,还是有点不舒服的感觉,还是用了翻译器
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 outputSample 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财务管理的更多相关文章
- Java数组练习题小结
//2015/07/07 //Java数组小小练习题 /* 3. 写一个函数,计算一个整数数组的平均值 4. 自定义一个整数数组a,读入一个整数n,如果n 在数组中存在,则输出n 的下标:如果不存在, ...
- Java循环和数组练习题:打印素数升级版
前两天一个小伙伴问了我一个数组的练习题,我一看思路很清晰,就是打印素数加了个数组.没想到写的时候啪啪打脸,终究还是没逃过眼高手低.本来不打算发出来了,因为发出来愈发显得我很菜,最后还是打算分享出来,一 ...
- Java学习笔记6(循环和数组练习题)
1.输出100到1000的水仙花数: public class LoopTest{ public static void main(String[] args){ int bai = 0; int s ...
- 【图文+视频新手也友好】Java一维数组详细讲解(内含练习题答案+详解彩蛋喔~)
目录 视频讲解: 一.数组的概述 二.一维数组的使用 三.Arrays工具类中的sort方法(sort方法用的多,我们具体讲一下) 四.数组中的常见异常 五.一维数组练习题 六.彩蛋(本期视频使用的P ...
- NSArray数组的学习总结
1.不可变数组NSArray NSArray是不可变的,而且只能储存Object-c对象.另外,数组的最后一个元素一定是nil,表示结束. 注:这些集合类只能收集cocoa对象(NSOjbect对象) ...
- awk巩固练习题
第1章 awk数组练习题 1.1 文件内容(仅第一行) [root@znix test]# head -1 secure-20161219 access.log ==> secure-20161 ...
- Ping pong(树状数组求序列中比某个位置上的数小的数字个数)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2492 Ping pong Time Limit: 2000/1000 MS (Java/Others) ...
- day04_数组
数组 学习目标: 1. jvm内存图入门 2. 一维数组的使用 3. 二维数组的使用 4. 数组的内存结构 5. 数组中常见算法 6. 数组中常见的异常 一.JVM内存图入门 java程序运行在jvm ...
- awk高级进阶
第1章 awk数组练习题 1.1 文件内容(仅第一行) [root@znix test]# head -1 secure-20161219 access.log ==> secure-20161 ...
随机推荐
- android动态设置组件LayoutParams
开发中经常用到动态设置组件的LayoutParams,之前开发遇到的问题如下: LinearLayout.LayoutParams params = new LinearLayout.LayoutPa ...
- Linux下tar压缩解压缩命令详解
tar -c: 建立压缩档案-x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个.下面的 ...
- 使用git和github管理自己的项目---基础操作学习[转]
原文: https://segmentfault.com/a/1190000003728094 我是通过看廖雪峰的git教程学习的,真的是极好的,以下是我学习过程中的总结,记录下来,方便自己参考以熟悉 ...
- 解决64bit不能连接access的问题
原有的程序迁移至64位,结果调用数据库时出错,原因是jet驱动没有64位的,得换用64位的驱动程序: 1. 下载运行 AccessDatabaseEngine_x64.exe (http://ww ...
- js垃圾回收(转
和C#.Java一样JavaScript有自动垃圾回收机制,也就是说执行环境会负责管理代码执行过程中使用的内存,在开发过程中就无需考虑内存分配及无用内存的回收问题了.JavaScript垃圾回收的机制 ...
- 修改.bashrc文件PATH变量错误导致系统大部分命令失效
修改.bashrc环境变量,在文件最后添加openssl变量, 本来应该写 export PATH=$PATH:/usr/local/openssl/bin 误写成 export PATH=/usr/ ...
- tomcat和springboot访问日志及分析
1.Tomcat设置访问日志 <Host name="localhost" appBase="webapps" unpackWARs="true ...
- SQL Server 之 子查询与嵌套查询
当由where子句指定的搜索条件指向另一张表时,就需要使用子查询或嵌套查询. 1 子查询 子查询是一个嵌套在select.insert.update或delete语句或其他子查询中的查询.任何允许使用 ...
- 前端 -----函数和伪数组(arguments)
函数 函数:就是将一些语句进行封装,然后通过调用的形式,执行这些语句. 函数的作用: 将大量重复的语句写在函数里,以后需要这些语句的时候,可以直接调用函数,避免重复劳动. 简化编程,让编程模块化. ...
- 解决FTPClient上传文件为空,显示0字节
JAVA使用FTPClient上传文件时总是为空,而使用FileZilla客户端时却不会. 后来查了下资料,FTP服务器有被动模式和主动模式.(具体查另外资料) 在JAVA中将FTPClient设置为 ...