#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);
}

最新文章

  1. Permission denied user=hadoop access=WRITE inode=root rootsupergroup rwxr
  2. PostgreSQL笔记
  3. C#异常Retry通用类
  4. Altera SoC与Matlab的联合---第一步 软件安装与硬件测试
  5. BZOJ4196——noi2015软件包管理器
  6. mysql distinct跟group by性能
  7. 文字排版--斜体(font-style)
  8. javascirpt的apply和call
  9. 关于fork()函数的作用
  10. ABP学习笔记
  11. POPTEST老李谈Debug和Release的区别(c#)
  12. Python 爬取淘宝商品信息和相应价格
  13. 如何提高使用Java反射的效率?
  14. asp.net获取当前请求的url
  15. piggy.lzo
  16. 知识点---js监听手机返回键,回到指定界面
  17. spring cloud(学习笔记)高可用注册中心(Eureka)的实现(二)
  18. Android应用开发-网络编程(一)
  19. what&#39;s the 回撤
  20. MsgWaitForMultipleObjects_测试

热门文章

  1. http状态码_____ 204/206/200
  2. HTML5基础 实例
  3. LightOJ1199 Partition Game
  4. POJ 3281 Dining(网络流-拆点)
  5. KEIL MDK 算式优先级 备忘
  6. springboot中的pom文件是如何管理依赖的
  7. Python生成器的用法
  8. php数组去重、魔术方法、redis常用数据结构及应用场景
  9. django----聚合查询 分组 F与Q查询 字段 及其 参数
  10. 使用 Vue + TypeScript 时项目中常用的装饰器