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. CentOS7 安装LNMP(Linux+Nginx+MySQL+PHP)

    由于工作须要,须要学习php,本来想安装lamp的可是考虑到如今nginxserver有良好的性能且应用广泛. 这里我决定搭建Linux(CentOS7+Nginx+MySQL+PHP)下的webse ...

  2. OLE-DB 操作excel 基本

    1 方法用例   *&---------------------------------------------------------------------* *& 本程序总结了常 ...

  3. IOS 代码管理工具

    代码管理工具国内主要用的是SVN 国外主要是Git

  4. cocos2dx 碰撞检测

    //必须 要有float类型的参数 void MainScene::updateFrame(float dt) { if (spriteTest != NULL && spriteTe ...

  5. sql 创建临时表

    declare @channelid varchar(100) set @channelid='''WH00026'',''WH00083''' declare @sql varchar(1000) ...

  6. 文件:因为懂你,所以永恒 - 零基础入门学习Python028

    文件:因为懂你,所以永恒 让编程改变世界 Change the world by program 因为懂你,所以永恒 大多数的程序都遵循着:输入->处理->输出的模型,首先接受输入数据,然 ...

  7. unity3D对象的显示和隐藏

    SetActive/active/SetActiveRecursively 后两者比较旧,现在通常用第一个SetActive 必须先new一个gameobject对象用于实例化,然后再设置其activ ...

  8. POJ 2888 Magic Bracelet(burnside引理+矩阵)

    题意:一个长度为n的项链,m种颜色染色每个珠子.一些限制给出有些颜色珠子不能相邻.旋转后相同视为相同.有多少种不同的项链? 思路:这题有点综合,首先,我们对于每个n的因数i,都考虑这个因数i下的不变置 ...

  9. LeetCode_Search a 2D Matrix

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

  10. KEIL 程序定位

    用Keil做51的开发也4年多了,代码量基本上维持在5~10K左右,说大不大,说小也不小,也就是个中等货色.这段期间工作上难得有稍许的空间,潜心研究了一下keil中如何在 CODE中定位C程序的方法. ...