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 ...
随机推荐
- 一个js编写全选、弹出对话框、ajax-json的案例
js功能有:全选.弹出对话框.使用json传输ajax数据:不想在写多余的文字了,直接上代码: <%@ page language="java" contentType=&q ...
- 事关Animation Tree的工作随笔(二)
上回说到,游戏项目中客观会遇到逻辑状态的复杂性和动画状态的单一性之间的矛盾,那么Animation Tree是如何解决这个问题的呢? 这又需要引入一个定律:就是逻辑状态无论有多么复杂,但一套逻辑状态组 ...
- [Javascript] Task queue & Event loop.
Javascript with Chorme v8 engine works like this : For Chorme engine, v8, it has call stack. And all ...
- QT5 r 加入qwtplot3d 三维库
qwtplot3d是基于QtOpenGL开发的,也是qwt库的三维库,我使用的是qwtplot3d-0.2.7.zip版本. 步骤跟编译qwt库一样(不明白可以看回前面写的一篇文章“Q ...
- JSP实现分页功能
分页须知知识点: (1)JDBC2.0的可滚动结果集. (2)HTTP GET请求. 一.可滚动结果集 Connection con = DriverManager.getConnection( ...
- LoadRunner录制回放脚本RecContentType=application/json报错
今天做一个新项目,项目系统的框架是用SSH,特意查看了一下项目源码,用的ajax提交比较多,主要的问题是该系统对IE(8~10)浏览器都不兼容,无法进行录制. 是问题,总有解决的办法! 我本机为Loa ...
- VCS仿真生成vpd文件(verilog)
VCS仿真生成vpd文件(verilog) 一.环境与文件 Linux平台 csh环境 VCS 64bit 代码文件请参考<一个简单的Verilog计数器模型> 二.开始仿真 1.com ...
- aspx生成验证码
//定义方法 public partial class VerificationCode : System.Web.UI.Page { string ImagePath = &qu ...
- linux虚拟机centos64位_6.5+VM10安装oracle11g图文详解
注意: vi基本命令:i--编辑状态 退出编辑并保存时先按ESC键,再按符合“:wq”或者":x"即可注意每个步骤时的当前用户,是root还是oracle 以root用户登录虚机 ...
- oracle 自动添加序号列 排序
select HSL.sortno, HSL.B, HSL.A, row_n ...