Jpeg

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

standard input/output  Announcement

 
  • 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

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
Output
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(模拟)的更多相关文章

  1. C# 通过模拟http请求来调用soap、wsdl

    C#调用webservice的方法很多,我说的这种通过http请求模拟来调用的方式是为了解决C#调用java的远程API出现各种不兼容问题. 由于远程API不在我们的控制下,我们只能修改本地的调用代码 ...

  2. 自己动手模拟开发一个简单的Web服务器

    开篇:每当我们将开发好的ASP.NET网站部署到IIS服务器中,在浏览器正常浏览页面时,可曾想过Web服务器是怎么工作的,其原理是什么?“纸上得来终觉浅,绝知此事要躬行”,于是我们自己模拟一个简单的W ...

  3. C++基础——模拟事务 (1)COMMAND模式

    =================================版权声明================================= 版权声明:原创文章 禁止转载  请通过右侧公告中的“联系邮 ...

  4. curl 模拟登录微信公众平台带验证码

    这段时间一直写个项目, 从切图到前端到后台都要搞定,真tm累. 今天下午手残,不停用错误的密码去模拟登录微信公众平台,结果后来出现验证码,瞬间悲剧(菜鸟从来没搞过带验证码的). 研究了一下,发现其实很 ...

  5. c# 模拟 网页实现12306登陆、自动刷票、自动抢票完全篇

    这一篇文章,我将从头到尾教大家使用c#模拟网页面登陆12306网站,自动刷票,选择订票人,到最后一步提交订单.研究过HTTP协议的童鞋们都知道,我们在访问网站时,是有两种方式的,POST和GET方式, ...

  6. 模拟登陆115网盘(MFC版)

    [cpp] view plain copy // 模拟登陆115网盘 #include <afxinet.h> // 包含相关的头文件 /* 用抓包工具抓包可得到需要提交的数据,然后模拟提 ...

  7. java 网络编程 模拟browser

    --java模拟实现browser,主要代码: package socket; import java.io.*; import java.net.*; public class MyHttpClie ...

  8. 使用C#模拟ASP.NET页面中按钮点击

    c# 模拟Asp.net页面中的某个按钮的点击,向web服务器发出请求 主要就组织要提交的数据,然后以post方式提交. 假设我们有如下的网页 1 <% @ Page Language = &q ...

  9. c# winform实现网页上用户自动登陆,模拟网站登录

    using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO ...

随机推荐

  1. Windows使用WxWidgets开发界面(c++)环境搭建

    一直想学习wxWidgets,之前使用的都是wxPython,现在终于鼓起勇气学习这个了,发现原来是基于vc6.0开发的.所以最好的学习办法就是安装vistual studio 2010,方便学习看代 ...

  2. NSLog用法,打印日志

    要输出的格式化占位:   %@ 对象 %d, %i 整数 %u   无符整形 %f 浮点/双字 %x, %X 二进制整数 %o 八进制整数 %zu size_t %p 指针 %e   浮点/双字 (科 ...

  3. Entity Framework - Func引起的数据库全表查询

    原文:http://www.cnblogs.com/dudu/archive/2012/04/01/enitity_framework_func.html 使用 Entity Framework 最要 ...

  4. AutoMapper2

    1.嵌套映射 namespace Second { class Program { static void Main(string[] args) { Mapper.CreateMap<Oute ...

  5. FineUI模拟树下拉列表

    模拟树的下拉列表 很多时候,我们希望在下拉列表中显示简单树状的层次结构,在菜单设置.机构设置等场景下这个需求尤为突出.也是基于项目需求的考虑,FineUI增加了模拟树的下拉列表的功能,显示效果如下所示 ...

  6. JAVA与JSON的序列化、反序列化

    package com.linkage.app.memcache; import java.util.HashMap;import java.util.Map.Entry; import net.sf ...

  7. C/C++中的switch使用

    代码: #include <iostream> #include <string> #include <cstdio> using namespace std; i ...

  8. c#按键Up和Down对Textbox的内容加1减1

    private void textBox_proc1value_KeyDown(object sender, KeyEventArgs e) { Keys key = e.KeyCode; if (e ...

  9. Oracle 10.2数据库管理员指南-27章

    27使用调度程序 Oracle Database provides database job capabilities through Oracle Scheduler (the Scheduler) ...

  10. C语言函数指针变量和指针函数以及指针数组

    C语言中,一个函数总是占用一段连续的内存区,而函数名就是该函数所占内存区的首地址.我们可以把函数的这个首地址(或称入口地址)赋予一个指针变量,使该指针变量指向该函数.然后通过指针变量就可以找到并调用这 ...