Skip to content

A C program that generates an NxN matrix with random integers (0-10) and performs a reversal transformation on elements located along both the main and secondary diagonals.

License

Notifications You must be signed in to change notification settings

ShotsMan2/Matrix-Diagonal-Reverser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Matrix Diagonal Reverser

This project implements a matrix transformation algorithm in C. It specifically targets the Main Diagonal and Anti-Diagonal of a square matrix and reverses the order of elements within them.

⚙️ Algorithm Logic

  1. Initialization:
    • Generates an $N \times N$ matrix with random values $[0, 10]$.
  2. Extraction:
    • Identifies elements on the Main Diagonal ($i, i$) and Anti-Diagonal ($i, N-1-i$).
  3. Transformation (Reversal):
    • The element at the top-left is swapped with the value that would be at the bottom-left/right depending on the reversal logic.
    • Effectively performs a spatial inversion of the diagonal values.

🚀 Example Transformation

Input Matrix (Diagonal Elements):

1   .   55
.   2   .
44  .   3

About

A C program that generates an NxN matrix with random integers (0-10) and performs a reversal transformation on elements located along both the main and secondary diagonals.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages