# 50173. Matrix Operations

## Problem Description

Write functions to rotate and transpose an 8 by 8 matrix.

1000000100000000000001000000000000000000000000000100000010000100


We can represent this matrix with a C99 uint_64, which has 64 bits, where the least significant 8 bits are the first row of the matrix, and so on, until the most significant 8 bits are the last row of the matrix.

lowbit                                                   highbit0         1         2         3         4         5         601234567890123456789012345678901234567890123456789012345678901231000000100000000000001000000000000000000000000000100000010000100


Now given a matrix as a C99 unsigned 64 bit integer, you need to implement the following functions.

• void printMatrix(uint64_t* matrix);
Print a matrix and its relative uint_64 as indicated above.

• void rotateMatrix(uint64_t* matrix);
Rotate a matrix clockwise. Then the matrix will like this.

1000000101000000000000000000000000000000100001000000000000000001

• void transposeMatrix(uint64_t *matrix); Transpose a matrix. Then the matrix will like this.

1000000100000010000000000000000000000000001000010000000010000000


## Source codes

### main.c

1234567891011121314151617181920#include <stdio.h>#include "matrixOperations.h"#include<stdint.h> int main() {   uint64_t num;   char operation;   scanf("%lu", &num);   while (1) {       scanf("%c", &operation);       if (operation == 'p') {           printMatrix(&num);           break;       } else if (operation == 'r')           rotateMatrix(&num);       else if (operation == 't')           transposeMatrix(&num);   }   return 0;}


### matrixOperations.h

1234#include<stdint.h>void printMatrix(uint64_t *matrix);void rotateMatrix(uint64_t *matrix);void transposeMatrix(uint64_t *matrix);


## Inputs Format

In the input files, the first line is the initial value of the matrix. The following lines are operations. r is for rotateMatrix, t is for transposeMatrix and p is for printMatrix.

## Outputs Format

There are nine lines in the output. The first line is the uint64_t value of the matrix and the last eight lines are the matrix.

### Sample Input 1

2378463553207140481rp


### Sample Output 1

92234083207384930571000000101000000000000000000000000000000100001000000000000000001


### Sample Input 2

2378463553207140481tp


### Sample Output 2

722027295728108811000000100000010000000000000000000000000001000010000000010000000


### Sample Input 3

2378463553207140481rtp


### Sample Output 3

92954648152647931211000010001000000000000000000000000000000000001000000000010000001