Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int matriz[10][10] = {};
- int filas = 0;
- int columnas = 0;
- int i;
- int j;
- int matrizRotada[10][10] = {};
- int angulo = 0;
- int k;
- scanf("%d%d",&filas,&columnas);
- scanf("%d",&angulo);
- for(i = 0; i < filas;i++){
- for(j = 0; j < columnas;j++){
- scanf("%d",&matriz[i][j]);
- }
- }
- if(angulo % 90 != 0 ){
- printf("Angulo no valido");
- return 0;
- }
- while(angulo > 360){
- angulo = angulo - 360;
- }
- k = columnas - 1;
- if(angulo == 90) {
- for(i = 0; i < columnas;i++) {
- for(j = 0; j < filas; j++) {
- matrizRotada[i][j] = matriz[j][k];
- }
- k--;
- }
- for(i= 0;i < columnas;i++) {
- for(j = 0; j < filas;j++) {
- printf("%d ",matrizRotada[i][j]);
- }
- printf("\n");
- }
- }
- else{
- if(angulo == 180) {
- for(i = 0; i < filas;i++) {
- for(j = 0; j < columnas; j++) {
- matrizRotada[i][j] = matriz[filas-i-1][columnas-j-1];
- }
- }
- for(i= 0;i < filas;i++) {
- for(j = 0; j < columnas;j++) {
- printf("%d ",matrizRotada[i][j]);
- }
- printf("\n");
- }
- }
- else{
- k = columnas - 1;
- if(angulo == 270) {
- for(i = 0; i < columnas;i++) {
- k = 0;
- for(j = (filas - 1); j >= 0; j--) {
- matrizRotada[i][k] = matriz[j][i];
- k++;
- }
- k--;
- }
- for(i= 0;i < columnas;i++) {
- for(j = 0; j < filas;j++) {
- printf("%d ",matrizRotada[i][j]);
- }
- printf("\n");
- }
- }
- else{
- for(i= 0;i < filas;i++) {
- for(j = 0; j < columnas;j++) {
- printf("%d ",matriz[i][j]);
- }
- printf("\n");
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment