当前位置:网站首页>pictures rotating
pictures rotating
2022-04-22 08:35:00 【True question OK】
R7-17 Image rotation (30 branch )
A two-dimensional picture consists of pixels , Currently, grayscale images use a 0-255 The integer between represents the pixel value of a pixel point . Program to complete the picture rotation control program .
This topic requires reading 2 It's an integer m and n(<=20), As the length and width of the picture . Input 1 It's an integer r, As the angle of rotation ( Input only 90 180 -90 One of them ,90 Indicates that the graph rotates to the left 90 degree ,-90 Indicates that the graph rotates to the right 90 degree ). Then enter the pixel value of the picture according to the row and column ,
Input format :
first line :2 It's an integer m and n(<=20)
The second line :2 It's an integer r( Can only be 90 180 -90 One of them , Otherwise prompt :angle data error
After the third line : Input m That's ok n Integer data of column , Must be in 0-255 Between , Otherwise prompt :matrix data error
All the above inputs are integers , If there is non integer data input , Unified tips :data type error
Output format :
Rotate the image matrix data as required
sample input :
Here's a set of inputs . for example :
3 4
90
1 2 3 4
5 6 7 8
9 10 11 12
sample output :
Here is the corresponding output . for example :
4 8 12
3 7 11
2 6 10
1 5 9
R7-17 Image rotation (30 branch )
A two-dimensional picture consists of pixels , Currently, grayscale images use a 0-255 The integer between represents the pixel value of a pixel point . Program to complete the picture rotation control program .
This topic requires reading 2 It's an integer m and n(<=20), As the length and width of the picture . Input 1 It's an integer r, As the angle of rotation ( Input only 90 180 -90 One of them ,90 Indicates that the graph rotates to the left 90 degree ,-90 Indicates that the graph rotates to the right 90 degree ). Then enter the pixel value of the picture according to the row and column ,
Input format :
first line :2 It's an integer m and n(<=20)
The second line :2 It's an integer r( Can only be 90 180 -90 One of them , Otherwise prompt :angle data error
After the third line : Input m That's ok n Integer data of column , Must be in 0-255 Between , Otherwise prompt :matrix data error
All the above inputs are integers , If there is non integer data input , Unified tips :data type error
Output format :
Rotate the image matrix data as required
sample input :
Here's a set of inputs . for example :
3 4
90
1 2 3 4
5 6 7 8
9 10 11 12
3 4
180
1 2 3 4
5 6 7 8
9 10 11 12
sample output :
Here is the corresponding output . for example :
4 8 12
3 7 11
2 6 10
1 5 9
import java.util.Scanner;
public class J_17 {
public static void main(String[] args) {
// TODO Automatically generated method stubs
@SuppressWarnings("unused")
int a = 0, b = 0, c = 0, f = 0;
@SuppressWarnings("unused")
int i = 0, j = 0;
@SuppressWarnings("unused")
int d[][] = new int[21][21];
@SuppressWarnings({ "unused", "resource" })
Scanner sc = new Scanner(System.in);
if (sc.hasNextInt()) {
a = sc.nextInt();
} else {
f = 1;
}
if (sc.hasNextInt()) {
b = sc.nextInt();
} else {
f = 1;
}
if (sc.hasNextInt()) {
c = sc.nextInt();
if (c != 90 && c != -90 && c != 180) {
System.out.println("angle data error");
} else {
for (i = 0; i < a; i++) {
for (j = 0; j < b; j++) {
if (sc.hasNextInt()) {
d[i][j] = sc.nextInt();
} else {
f = 1;
}
if (!(d[i][j] >= 0 && d[i][j] <= 255)) {
System.out.println("matrix data error");
}
}
}
if (f == 1) {
System.out.println("data type error");
} else if (c == 90) {
for (i = b - 1; i >= 0; i--) {
for (j = 0; j < a; j++) {
if (j == 0)
System.out.print(d[j][i]);
else
System.out.print(" " + d[j][i]);
}
System.out.print("\n");
}
} else if (c == -90) {
for (i = 0; i < b; i++) {
for (j = a - 1; j >= 0; j--) {
if (j == a - 1)
System.out.print(d[j][i]);
else
System.out.print(" " + d[j][i]);
}
System.out.print("\n");
}
} else {
for (i = a - 1; i >= 0; i--) {
for (j = b - 1; j >= 0; j--) {
if (j == b - 1)
System.out.print(d[i][j]);
else
System.out.print(" " + d[i][j]);
}
System.out.print("\n");
}
}
}
} else {
f = 1;
System.out.println("angle data error");
}
}
}
版权声明
本文为[True question OK]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220743122515.html
边栏推荐
- 【论文阅读】【3d目标检测】Voxel Set Transformer: A Set-to-Set Approach to 3D Object Detection from Point Clouds
- Cesium加载地形数据(cesiumlab制作地形数据),从源数据到地形服务
- oracle数据库表空间容量查询及扩容
- 第2关:子节点创建、列出、删除
- 构造函数与toString
- shell监控IBM MQ队列深度,10s扫描三次,有两次以上深度值超过5时,则输出队列名称和深度值。
- Efcore global query filter
- npm发布一个项目到npm库?
- Detailed analysis of viewpager usage
- Teach you how to realize the pull-down refresh and pull-up load of recyclerview
猜你喜欢

社会工程学之黑客七宗罪——傲慢(Hooking)

Nacos Foundation (1): what is configuration center & introduction to Nacos

The industrialization of SCRM has accelerated, and the manufacturing industry has begun to play with private traffic

第3关:节点配额及其他命令

What do you know about the well-known public DNS servers in China

Golang learning, pointer, loop control, correlation

Mapbox设置官方地图语言为中文

shell笔记

Shell 命令脚本

【大话云原生】微服务篇-五星级酒店的服务方式
随机推荐
JS judge the element to the top and fix it
cesium坐标转换:不同坐标系之间的相互转换
On the modification of static database
【论文阅读】【3d目标检测】pvgnet
只有服务器,没有域名,怎么部署网站?
秋招求职总结分享
指针和字符串
累加器
二进制的前导的零
华为机试题——HJ53 杨辉三角的变形
WeChat official account - webpage authorization
Simple use of fresco - simpledraweeview
社会工程学之黑客七宗罪——贪婪(死亡之PING)
236. 二叉树的最近公共祖先(Medium)
kubernetes学习笔记
第1关:节点监听机制
客户端与服务器通信项目1
cesium 采集地形高度,采集模型高度 (异步方法,适合数据较多的时候)
客户端与服务器通信项目2
OLED显示驱动