当前位置:网站首页>图片旋转
图片旋转
2022-04-22 07:44:00 【真题OK撒】
R7-17 图片旋转 (30 分)
二维图片由一个个像素点组成,目前灰度图像使用一个0-255之间的整数表示某个像素点的像素值。编程完成图片旋转控制程序。
本题目要求读入2个整数m和n(<=20),作为图片的长宽尺寸。输入1个整数r,作为旋转角度(只能输入90 180 -90中的一个,90表示图形向左旋转90度,-90表示图形向右旋转90度)。然后按照行列输入图片像素值,
输入格式:
第一行:2个整数m和n(<=20)
第二行:2个整数r(只能是90 180 -90中的一个,否则提示:angle data error
第三行以后:输入m行n列的整数数据,必须在0-255之间,否则提示:matrix data error
以上输入的都是整数,若有非整数的数据输入,统一提示:data type error
输出格式:
按要求旋转后的图片矩阵数据
输入样例:
在这里给出一组输入。例如:
3 4
90
1 2 3 4
5 6 7 8
9 10 11 12
输出样例:
在这里给出相应的输出。例如:
4 8 12
3 7 11
2 6 10
1 5 9
R7-17 图片旋转 (30 分)
二维图片由一个个像素点组成,目前灰度图像使用一个0-255之间的整数表示某个像素点的像素值。编程完成图片旋转控制程序。
本题目要求读入2个整数m和n(<=20),作为图片的长宽尺寸。输入1个整数r,作为旋转角度(只能输入90 180 -90中的一个,90表示图形向左旋转90度,-90表示图形向右旋转90度)。然后按照行列输入图片像素值,
输入格式:
第一行:2个整数m和n(<=20)
第二行:2个整数r(只能是90 180 -90中的一个,否则提示:angle data error
第三行以后:输入m行n列的整数数据,必须在0-255之间,否则提示:matrix data error
以上输入的都是整数,若有非整数的数据输入,统一提示:data type error
输出格式:
按要求旋转后的图片矩阵数据
输入样例:
在这里给出一组输入。例如:
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
输出样例:
在这里给出相应的输出。例如:
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 自动生成的方法存根
@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");
}
}
}
版权声明
本文为[真题OK撒]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_51916951/article/details/124052155
边栏推荐
- 地图裁剪器,可以将图片裁剪成瓦片数据,主要用途是将高清卫星图像裁剪成瓦片图,可以做离线地图的开发,基于墨卡托坐标
- 7-34 delete duplicate characters (set usage) & 7-35 count the number of characters (unordered_map)
- spark sql 获取数组某index处元素
- 使⽤airtestIDE⽣成脚本,使⽤脚本运⾏
- npm发布一个项目到npm库?
- A preliminary understanding of Copula function
- 机器学习笔记 - 行列式
- Tita performance treasure: eight mistakes made by managers in performance appraisal
- 如何用c语言实现【猜数字游戏】
- Viewpager comprehensive summary
猜你喜欢

shell脚本学习笔记——正则表达式

Flutter GridView Demo
Introduction to smarttablayout

kubernetes学习笔记

【论文阅读】【3d目标检测】Voxel Set Transformer: A Set-to-Set Approach to 3D Object Detection from Point Clouds

94. 二叉树的中序遍历(Easy)

Fresco简单的使用—SimpleDraweeView

Flutter 判断网络可用性

Fluent listview loads more

SQL requirements processing - count the number of Mondays to Sundays in a given year
随机推荐
指针和数组(操作详解)
MaterialApp
电影票选座左右间隔为空不能选
Winsock编程接口实验:实现ipconfig
leaflet、cesium加载百度地图,加载自定义样式百度地图
MySQL in-depth study (3-2): other database tuning strategies
Pycharm terminal PIP installation error: "PIP" item is recognized as the name of cmdlet, function, script file or runnable program
地图裁剪器,可以将图片裁剪成瓦片数据,主要用途是将高清卫星图像裁剪成瓦片图,可以做离线地图的开发,基于墨卡托坐标
CPU的基本工作流程
【论文阅读】【3d目标检测】pvgnet
Mapbox设置官方地图语言为中文
Viewpager comprehensive summary
Informatics Aosai yibentong 1211: judge whether elements exist | openjudge 1.13 41: judge whether elements exist
Teach you how to realize the pull-down refresh and pull-up load of recyclerview
第3关:节点配额及其他命令
Flutter GridView Demo
A preliminary understanding of Copula function
EFCore优化之AsNoTracking
shell脚本学习——实战案例
1315. 祖父节点值为偶数的节点和(Medium)