Jpeg(模拟)
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
- Statements
In computing, JPEG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography . The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality,and JPEG typically achieves 10:1 compression with little perceptible loss in image quality. Entropy coding is a special form of lossless data compression. It involves arranging the image components in a "zigzag" order employing run-length encoding (RLE) algorithm that groups similar frequencies together, inserting length coding zeros, and then using Huffman coding on what is left.
Now i am so busy ,so i will give you a
square matrix that represents pixel intensities of the image.
Your task is simple: reconstruct the image so that the value in the ith row and jth column of the resulting image is the value of the (i * N + j)thpixel visited in the zigzag sequence .
Input
Your program will be tested on one or more test cases. The first line of the input contains a single integer T (1 ≤ T ≤ 100) the number of test cases. Followed by T test cases.
Each test case consists of N+1 lines. The first line contains an integer N (2 ≤ N ≤ 100). The next lines consists of an squared pixel matrix.
Output
For each test case print the required transformed matrix.
Sample Input
1 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
1 2 6 11 7 3 4 8 12 16 21 17 13 9 5 10 14 18 22 23 19 15 20 24 25
题解:水题,按照途中的划线访问,模拟下就好了;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN = ;
int num[MAXN * MAXN];
int mp[MAXN][MAXN];
int main(){
int T, N;
scanf("%d", &T);
while(T--){
scanf("%d", &N);
for(int i = ; i <= N; i++){
for(int j = ; j <= N; j++){
scanf("%d", &mp[j][i]);
}
}
int tp = ;
int x = , y = ;
num[tp++] = mp[x][y];
while(tp < N*N){
if(x + <= N)
num[tp++] = mp[++x][y];
else if(y + <= N)
num[tp++] = mp[x][++y];
while(x - >= && y + <= N){
num[tp++] = mp[--x][++y];
}
if(x == && y + <= N)
num[tp++] = mp[x][++y];
else if(y == N && x + <= N)
num[tp++] = mp[++x][y];
while(x + <= N && y - >= ){
num[tp++] = mp[++x][--y];
}
}
for(int i = ; i < N; i++){
for(int j = ; j < N; j++){
mp[i][j] = num[i * N + j];
}
}
for(int i = ; i < N; i++){
for(int j = ; j < N; j++){
if(j)printf(" ");
printf("%d", mp[i][j]);
}
puts("");
}
}
return ;
}
Jpeg(模拟)的更多相关文章
- C# 通过模拟http请求来调用soap、wsdl
C#调用webservice的方法很多,我说的这种通过http请求模拟来调用的方式是为了解决C#调用java的远程API出现各种不兼容问题. 由于远程API不在我们的控制下,我们只能修改本地的调用代码 ...
- 自己动手模拟开发一个简单的Web服务器
开篇:每当我们将开发好的ASP.NET网站部署到IIS服务器中,在浏览器正常浏览页面时,可曾想过Web服务器是怎么工作的,其原理是什么?“纸上得来终觉浅,绝知此事要躬行”,于是我们自己模拟一个简单的W ...
- C++基础——模拟事务 (1)COMMAND模式
=================================版权声明================================= 版权声明:原创文章 禁止转载 请通过右侧公告中的“联系邮 ...
- curl 模拟登录微信公众平台带验证码
这段时间一直写个项目, 从切图到前端到后台都要搞定,真tm累. 今天下午手残,不停用错误的密码去模拟登录微信公众平台,结果后来出现验证码,瞬间悲剧(菜鸟从来没搞过带验证码的). 研究了一下,发现其实很 ...
- c# 模拟 网页实现12306登陆、自动刷票、自动抢票完全篇
这一篇文章,我将从头到尾教大家使用c#模拟网页面登陆12306网站,自动刷票,选择订票人,到最后一步提交订单.研究过HTTP协议的童鞋们都知道,我们在访问网站时,是有两种方式的,POST和GET方式, ...
- 模拟登陆115网盘(MFC版)
[cpp] view plain copy // 模拟登陆115网盘 #include <afxinet.h> // 包含相关的头文件 /* 用抓包工具抓包可得到需要提交的数据,然后模拟提 ...
- java 网络编程 模拟browser
--java模拟实现browser,主要代码: package socket; import java.io.*; import java.net.*; public class MyHttpClie ...
- 使用C#模拟ASP.NET页面中按钮点击
c# 模拟Asp.net页面中的某个按钮的点击,向web服务器发出请求 主要就组织要提交的数据,然后以post方式提交. 假设我们有如下的网页 1 <% @ Page Language = &q ...
- c# winform实现网页上用户自动登陆,模拟网站登录
using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO ...
随机推荐
- [ASP.NET] 檔案讀寫權限問題
今天遇到一個問題,環境如下: IIS Server: Server 2008 R2 沒加域 File Server: Server 2003 加域 當我的Web程序需要把位於File Server的一 ...
- Javascript基础引用类型之Object
虽然说ECMAScript也是一门对象语言,但是它和其他面向对象语言还是有区别的,它不具有类和接口等基本结构.所以在ECMAScript中一般说类指的是引用类型.创建Object实例的方式有两种: 第 ...
- QQ在线联系代码
添加图文模块,标题地址:tencent://message/?uin=你的QQ号&Site=myqq&Menu=yes "你的QQ号"就写您自己的Q号 图片地址写: ...
- mysqlbinlog恢复数据
操作命令: 复制代码代码如下: show binlog events in 'mysql-bin.000016' limit 10; reset master 删除所有的二进制日志flush logs ...
- iOS开发-清理缓存功能的实现
移动应用在处理网络资源时,一般都会做离线缓存处理,其中以图片缓存最为典型,其中很流行的离线缓存框架为SDWebImage. 但是,离线缓存会占用手机存储空间,所以缓存清理功能基本成为资讯.购物.阅读类 ...
- TOJ3596 二维背包
3596. Watch The Movie Time Limit: 2.0 Seconds Memory Limit: 65536KTotal Runs: 424 Accepted Run ...
- C#随机生成连续多少个十六进制数字
1.调用系统函数生成全球唯一标识 Guid.NewGuid().ToString(); 2.生成16组十六进制数 ,)+Guid.NewGuid().ToString().Substring(,)+G ...
- (原+转)ubuntu终端输出彩色文字
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6066697.html 参考网址: http://www.tuicool.com/articles/jI ...
- 电脑文本text和部分文字出现其他语言乱码
1.文本的编码存在问题 解决办法: 将text文件打开>>文件(左上角)>>另存为>>选择其他格式的编码试试(在保存键左侧)>>保存再打开 2.系统区 ...
- ubuntu14.04中解压缩window中的zip文件,文件名乱码的解决方法
在windows上压缩的文件,是以系统默认编码中文来压缩文件.由于zip文件中没有声明其编码,所以linux上的unzip一般以默认编码解压,中文文件名会出现乱码. 通过unzip行命令解压,指定字符 ...