#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的更多相关文章

  1. RestTemplate实践

    什么是RestTemplate? RestTemplate是Spring提供的用于访问Rest服务的客户端,RestTemplate提供了多种便捷访问远程Http服务的方法,能够大大提高客户端的编写效 ...

  2. Smali 语法文档

    可以选择保存成pdf格式,查询起来挺方便的 if v0==0 go cond_0 if-eqz v0, :cond_0   if v0!=0 go cond_0 if-nez v0, :cond_0 ...

  3. 转载spring restemplate

    什么是RestTemplate? RestTemplate是Spring提供的用于访问Rest服务的客户端,RestTemplate提供了多种便捷访问远程Http服务的方法,能够大大提高客户端的编写效 ...

  4. TypesMethodsAndFields

    https://github.com/JesusFreke/smali/wiki/TypesMethodsAndFields Types dalvik's bytecode has two major ...

  5. JNI 资源释放

    JNI 编程实现了 native code 和 Java 程序的交互,因此 JNI 代码编程既遵循 native code 编程语言的编程规则,同时也遵守 JNI 编程的文档规范.在内存管理方面,na ...

  6. 基于 Android NDK 的学习之旅-----资源释放

    做上一个项目的时候因为与C引擎交互频繁,有时候会突然莫名其妙的的整个应用程序直接挂掉.因为我是学Java 开始的,所以对主动释放内存没多大概念(GC直接帮忙回收),后查询原因才知道是因为JNI 有些对 ...

  7. Java编程思想之十七 容器深入研究

    17.1 完整的容器分类方法 17.2 填充容器 import java.util.*; class StringAddress { private String s; public StringAd ...

  8. Java中Type接口及其子类

    简介 Type是Java 编程语言中所有类型的公共高级接口,和Object不同,Object是所有类的父类,即Object是Type的父类. 分类 原始类型(Class):不仅仅包含我们平常所指的类, ...

  9. 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 ...

随机推荐

  1. metronic 表格插件 datatables

    官方网站:https://datatables.net/ css引入:datatables.min.css && datatables.bootstrap.css && ...

  2. 自然语言处理(NLP)相关学习资料/资源

    自然语言处理(NLP)相关学习资料/资源 1. 书籍推荐 自然语言处理 统计自然语言处理(第2版) 作者:宗成庆 出版社:清华大学出版社:出版年:2013:页数:570 内容简介:系统地描述了神经网络 ...

  3. iOS app反编译

    对于APP store 上的应用都是加密的了,反编译起来有难度. 对于自己用xcode 编译的ipa 或者是其他渠道下载的ipa包都可以使用反编译工具进行反编译. https://cnbin.gith ...

  4. 掘金转载-手写一个Promise

    目录 一 什么是Promise ? 二 Promises/A+ 规范 2.1 术语 2.2 基本要求 2.2.1. Promise的状态 2.2.2. Then 方法 2.3 简易版实践 2.4 进一 ...

  5. vmware虚拟机扩大硬盘

    记录一下对vmware虚拟机扩大硬盘的过程.操作有风险,重要数据请先进行备份. 1.首先在vcenter中将虚拟机下电,然后编辑虚拟机,将虚拟机硬盘扩大.具体操作见下图 2.打开虚拟机电源,利用fdi ...

  6. Java修炼——文件字节输入输出流复制和缓冲流复制

    一:文件字节输入输出流复制 首先明确数据源和目的文件,然后就是"中转站",最后就是关闭 package com.bjsxt.ioproject; import java.io.Fi ...

  7. Python的面试题

    (1)怎么把一个字符串转换成整型? 可以使用int函数  如 int('3')   结果由字符串'3'变为整型3 (2)python内建数据类型有哪些? int .bool. str.list. ru ...

  8. Golang 在电商即时通讯服务建设中的实践

    马蜂窝技术原创文章,更多干货请搜索公众号:mfwtech ​即时通讯(IM)功能对于电商平台来说非常重要,特别是旅游电商. 从商品复杂性来看,一个旅游商品可能会包括用户在未来一段时间的衣.食.住.行等 ...

  9. 【React】282- 在 React 组件中使用 Refs 指南

    英文:Yomi Eluwande  译文:joking_zhang https://segmentfault.com/a/1190000019277029 使用 React 时,我们的默认思维方式应该 ...

  10. Redis的优缺点小结

    Redis(Remote Dictionary Server 远程数据服务),一个 Key-value(键值对)存储系统,典型的 NoSQL 数据库服务器. 优点: 1.支持丰富的数据类型,如:Str ...