C lang:Array_Multidimensional arrays
#include<stdio.h>
#include<windows.h>
#define YEARS 5
#define MONTHS 12
void color(short x);
int main(void)
{
//definition array
const float rain[YEARS][MONTHS] =
{
{1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 0.1, 0.2, 0.3},
{1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 0.1, 0.2, 0.3},
{1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 0.1, 0.2, 0.3},
{1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 0.1, 0.2, 0.3},
{1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 0.1, 0.2, 0.3}
};
const char mon[12][10] = {"January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December"};
int year, month;
int i,w;
float subtot, total, subtotv;
color(5);
printf(" Year Rainfall(inches)\n");
color(4);
for (year = 0, total = 0; year < YEARS; year++) // years cyclic out layer
{
for (month = 0, subtot = 0; month < MONTHS; month++) // month cyclic in layer
{
subtot = subtot + rain[year][month]; // per month count rain
}
total = total + subtot; // five years count rain
printf(" %d%11.2f\n",2016+year,total);
}
color(5);
w =0;
for(i = 0; i < MONTHS; i++)
printf("%13s",mon[i]);
printf("\n");
color(4);
for (month = 0; month < MONTHS; month++) // month cyclic out layer
{
for (year = 0, subtotv = 0; year < YEARS; year++) // years cyclic in layer
{
subtotv = subtotv + rain[year][month]; // sth month years count
}
// printf("%.1f\n",subtotv);
subtotv = subtotv / YEARS; // sth month years average
printf("%13.2f",subtotv);
// printf("%.1f\n---------\n",subtotv);
}
// printf("%.1f",rain[1][0]);
// printf("%.1f\n%.1f\n%.1f\n",subtot, total, subtotv);
color(16);
printf("\n");
printf("\n"); printf("\n"); printf("\n");
system("pause");
return 0;
}
void color(short x)
{
if(x >= 0 && x <= 15)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
C lang:Array_Multidimensional arrays的更多相关文章
- RestTemplate实践
什么是RestTemplate? RestTemplate是Spring提供的用于访问Rest服务的客户端,RestTemplate提供了多种便捷访问远程Http服务的方法,能够大大提高客户端的编写效 ...
- Smali 语法文档
可以选择保存成pdf格式,查询起来挺方便的 if v0==0 go cond_0 if-eqz v0, :cond_0 if v0!=0 go cond_0 if-nez v0, :cond_0 ...
- 转载spring restemplate
什么是RestTemplate? RestTemplate是Spring提供的用于访问Rest服务的客户端,RestTemplate提供了多种便捷访问远程Http服务的方法,能够大大提高客户端的编写效 ...
- TypesMethodsAndFields
https://github.com/JesusFreke/smali/wiki/TypesMethodsAndFields Types dalvik's bytecode has two major ...
- JNI 资源释放
JNI 编程实现了 native code 和 Java 程序的交互,因此 JNI 代码编程既遵循 native code 编程语言的编程规则,同时也遵守 JNI 编程的文档规范.在内存管理方面,na ...
- 基于 Android NDK 的学习之旅-----资源释放
做上一个项目的时候因为与C引擎交互频繁,有时候会突然莫名其妙的的整个应用程序直接挂掉.因为我是学Java 开始的,所以对主动释放内存没多大概念(GC直接帮忙回收),后查询原因才知道是因为JNI 有些对 ...
- Java编程思想之十七 容器深入研究
17.1 完整的容器分类方法 17.2 填充容器 import java.util.*; class StringAddress { private String s; public StringAd ...
- Java中Type接口及其子类
简介 Type是Java 编程语言中所有类型的公共高级接口,和Object不同,Object是所有类的父类,即Object是Type的父类. 分类 原始类型(Class):不仅仅包含我们平常所指的类, ...
- java数组、java.lang.String、java.util.Arrays、java.lang.Object的toString()方法和equals()方法详解
public class Test { public static void main(String[] args) { int[] a = {1, 2, 4, 6}; int[] b = a; in ...
随机推荐
- Magicodes.Sms短信库的封装和集成
简介 Magicodes.Sms是心莱团队封装的短信服务库,已提供Abp模块的封装. Nuget 新的包 名称 说明 Nuget Magicodes.Sms.Aliyun 阿里云短信库 Magicod ...
- eclipse m2eclipse 从Maven的本地库中读取依赖库
在Mac pro的终端中执行命令 mvn package 后,已经把该工程所需要的依赖库(dependancies)下载到本地库,但在把该工程 import 到 eclipse中时,发现m2eclip ...
- wait notify notifyAll await signal signalAll 的理解及示例
从常见的一道面试题开始,题目的描述是这样子的: 有三个线程分别打印A.B.C,请用多线程编程实现,在屏幕上循环打印10次ABCABC- 网上大都教了你怎么去实现,其实我也写过一篇 https://bl ...
- luogu P2985 [USACO10FEB]吃巧克力Chocolate Eating
题目描述 Bessie拿到了N (1 <= N <= 50,000)块巧克力.她决定想个办法吃掉这些巧克力,使得它在吃巧克力的这段时间里,最不开心的一天尽可能的开心.并且一共吃D (1 & ...
- [TimLinux] JavaScript input框的onfocus/onblur/oninput/onchange事件介绍
1. onfocus事件 input框获取到焦点时,触发了该事件,比如获取到焦点时,修改input框的背景色.这个功能其实可以使用css的伪类:focus来定义. 2. onblur事件 这个与onf ...
- Python之Flask项目开发【入门必学】
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理.作者:藤藤菜丶 Flask 安装Flask模块 创建一个Flask项目 运行 ...
- [ Coding七十二绝技 ] 如何利用Java异常快速分析源码
前言 异常一个神奇的东西,让广大程序员对它人又爱又恨.爱它,通过它能快速定位错误,经过层层磨难能学到很多逼坑大法.恨他,快下班的时刻,周末的早晨,它踏着七彩云毫无征兆的来了. 今天,要聊的是它的一项神 ...
- 学Maven,这篇万余字的教程,真的够用了!
1 Maven 介绍 1.1 为什么使用 Maven 由于 Java 的生态非常丰富,无论你想实现什么功能,都能找到对应的工具类,这些工具类都是以 jar 包的形式出现的,例如 Spring,Spri ...
- jmeter微信公众号接口测试实例
线程组 HTTP Cookie 管理器 HTTP 请求默认值 用户定义的变量 察看结果树 HTTP请求 响应断言 正则表达式提取器 线程组 HTTP Cookie 管理器 HTTP 请求默认值 用户定 ...
- Spring 学习,看松哥这一篇万余字干货就够了!
1. Spring 简介 我们常说的 Spring 实际上是指 Spring Framework,而 Spring Framework 只是 Spring 家族中的一个分支而已.那么 Spring 家 ...