浙江省赛problem 1009
来源:互联网 发布:坐标数据文件格式 编辑:程序博客网 时间:2024/04/28 06:25
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 5 Accepted Submission(s) : 6
Sometimes however, we may need a gray picture instead of a colorful one. One of the simplest way to transform a RGB picture into gray: for each pixel, we set the Red, Green and Blue level to a same value which is usually the average of the Red, Green and Blue level of that pixel (that is (r + g + b)/3, here we assume that the sum of r, g and b is always dividable by 3).
You decide to write a program to test the effectiveness of this method.
Input
The input contains multiple test cases!
Each test case begins with two integer numbers N and M (1 <= N,M <= 100) meaning the height and width of the picture, then threeN *M matrices follow; respectively represent the Red, Green and Blue level of each pixel.
A line with N = 0 and M = 0 signals the end of the input, which should not be proceed.
Output
For each test case, output "Case #:" first. "#" is the number of the case, which starts from 1. Then output a matrix ofN *M integers which describe the gray levels of the pixels in the resultant grayed picture. There should beN lines withM integers separated by a comma.
Sample Input
2 2
1 4
6 9
2 5
7 10
3 6
8 11
2 3
0 1 2
3 4 2
0 1 2
3 4 3
0 1 2
3 4 4
0 0
Sample Output
Case 1:
2,5
7,10
Case 2:
0,1,2
3,4,3
#include<stdio.h>int main(){ int a[102][102],m,n,i,j,k,flag,sum=1; while(scanf("%d%d",&m,&n)!=EOF&&m&&n) { for(i=0; i<m; i++) { for(j=0; j<n; j++) { a[i][j]=0; } } k=3; while(k--) { for(i=0; i<m; i++) { for(j=0; j<n; j++) { scanf("%d",&flag); a[i][j]+=flag; } } } printf("Case %d:\n",sum); for(i=0; i<m; i++) { for(j=0; j<n; j++) { if(j)printf(","); printf("%d",a[i][j]/3); } printf("\n"); } sum++; } return 0;}本题核心算法:求三个数的平均数…………
- 浙江省赛problem 1009
- 浙江省赛problem 1003
- 浙江省赛problem 1002(BF)
- ZOJ-3326-An Awful Problem【7th浙江省赛】【模拟】
- 浙江省赛
- 2014浙江省赛总结
- 组队_浙江省赛
- 2014浙江省赛总结
- 2015年浙江省赛
- 2015浙江省赛
- 2017 浙江省赛
- 【第十届浙江省ACM省赛】Problem A—— Applications
- 浙江省省赛K题
- 浙江省省赛J题
- 9th 浙江省赛总结
- 第十一届浙江省赛题目
- 浙江省赛 G.Lunch Time
- 2015年浙江省赛总结
- oracle 中的elseif 和elsif
- Java 单例模式详解
- C#My计算器源代码
- 编程珠玑(2)第四章阅读笔记
- ubuntu gdbm 问题解决
- 浙江省赛problem 1009
- 生成随机长度的字符串
- Mac os android源码下载,环境配置 mountain lion10.8.2 配置源码下载环境,并编译源码
- 给创业者的真言
- 第一周项目二
- Android.mk简介 .
- [AudioTrack]使用AudioTrack播放PCM音频数据
- 我的一些define和include【每次直接补全】【有些代码里没有这部分内容看起来可能会不知道是啥】
- Javascript keyevent