暑期个人赛--第三场--B
来源:互联网 发布:淘宝店铺种类 编辑:程序博客网 时间:2024/06/11 09:48
B. 学姐的旋转图像 2014新生暑假个人排位赛03
时间限制 1000 ms 内存限制 65536 KB
题目描述
学姐在学图形学,然后写了一个能让图片逆时针转圈的程序。这个程序很厉害,只要输入灰度图片和旋转过的角度(90的倍数),就可以输出一个新图片。给你一张图片的灰度矩阵,和它已转过的角度,请输出图片旋转前的灰度图矩阵。
输入格式
接下来给出图片扫描稿的高H和宽W,图片的灰度矩阵,高宽都小于500,题目其他的所有数值都小于int的范围。多组数据,组数小于20,EOF结束。
输出格式
一个矩阵
输入样例
2 2 180
0 1
1 2
输出样例
2 1
1 0
赛中提交情况:WA WA AC
赛后提交情况:Y
一道模拟题,思路很简单,
度数先整除90,然后模4,再用一个数组读入,用对应方式输出即可。
赛中WA的原因是:
(1)没读懂题意,逆时针还是顺时针
(2)输出时没换宽和高(i,j)
#include <iostream>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string>#include <vector>#include <list>#include <map>#include <queue>#include <stack>#include <bitset>#include <algorithm>#include <numeric>#include <functional>#define maxn 500005using namespace std;int a[502][502],b[502][502];int main(){ int rad,k,l; while(scanf("%d %d %d",&k,&l,&rad)!=EOF){ rad/=90; rad%=4; for(int i=0;i<k;i+=1){ for(int j=0;j<l;j+=1){ scanf("%d",&a[i][j]); } } if(rad==2){ for(int i=k-1;i>=0;i-=1){ for(int j=l-1;j>=0;j-=1){ printf("%d",a[i][j]); if(j!=0){ printf(" "); } } printf("\n"); } } else if(rad==1){ for(int i=0;i<l;i+=1){ for(int j=k-1;j>=0;j-=1){ printf("%d",a[j][i]); if(j!=0){ printf(" "); } } printf("\n"); } } else if(rad==3){ for(int i=l-1;i>=0;i-=1){ for(int j=0;j<k;j+=1){ printf("%d",a[j][i]); if(j!=k-1){ printf(" "); } } printf("\n"); } } else if(rad==0){ for(int i=0;i<k;i+=1){ for(int j=0;j<l;j+=1){ printf("%d",a[i][j]); if(j!=l-1){ printf(" "); } } printf("\n"); } } //printf("\n"); } return 0;}
0 0
- 暑期个人赛--第三场--B
- 暑期个人赛--第三场--A
- 暑期个人赛--第三场--C
- 暑期个人赛--第三场--D
- 暑期个人赛--第四场--B
- 暑期个人赛--第一场--B
- 暑期个人赛--第二场--B
- 暑期个人赛--第五场--B
- 暑期个人赛--第七场--B
- 暑期个人赛--第三场--E(待A)
- 暑期个人赛--第三场--E(待A....)
- 暑期个人赛--第六场--B(常复习~!!!)
- 2013 - ECJTU 暑期训练赛第三场-problem-B
- 暑期个人赛第一场
- 暑期个人赛第二场
- 暑期个人赛--第八场--B(关于手写队列的启示+题目有坑)
- (待切,标记上)暑期个人赛--第九场--B
- 暑期个人赛--第一场--E
- iOS学习之 plist文件的读写
- 马航客机在乌克兰边境被击落 机上人员全遇难(代发csdn联系QQ:278873228)
- ARC下使用单例模式
- 你们都满足以下的工作考核吗
- 嵌入Silverlight 组件的对象 Silverlight 中 Param 参数
- 暑期个人赛--第三场--B
- 【神经网络学习笔记】遗传算法优化BP神经网络-非线性函数拟合
- poj_1080 Human Gene Functions
- 【Node.js学习笔记1--模块 npm】
- hihocoder 1033 交错和
- Silverlight 与 JS交互
- 结合nginx源码 学习 error_page 和 proxy_intercept_errors 指令的关系
- [leetcode] Remove Duplicates from Sorted List
- 生产者/消费者问题的多种Java实现方式