current position:Home>Given a matrix of N x n, find the matrix after 90 degrees of rotation
Given a matrix of N x n, find the matrix after 90 degrees of rotation
2022-02-02 11:47:42 【CSDN Q & A】
First enter a n ( n ≤ 10 ) , then n That's ok n Column The data represents a matrix , The output matrix rotates clockwise 90 Matrix after degree . When there is no input , Program end .
Refer to the answer 1:
#include <iostream>#include <vector>int main(){ int n; std::cin >> n; if (n <= 0) { std::cout << "invalid matrix size\n"; return -1; } int size = n * n; std::vector<float> A(size); for (int i = 0; i < size; i++) std::cin >> A[i]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { std::cout << A[(n - j - 1 )* n + i] << ' '; } std::cout << '\n'; } return 0;}
Refer to the answer 2:
copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021147410060.html
The sidebar is recommended
- How to read text from TXT document, write it into excel and run it in reverse?
- Calculation of joint torque of detal manipulator
- Give a string representing the date and ask what day of the year it is
- [Vue] setting @ media to query font size is not effective
- How to use the ecarts national map to the city? I CV changed other people's codes and key values. Now this is the case
- Hbuilderx
- Design database (agricultural products sales database, clothing sales database and stamen sales database)
- Let's see if the course sequence of distributed architect is correct
- What's the matter with me? Please answer
- Link failure of distributed task scheduling
guess what you like
-
The bean tag calls auto assembly and has been given a parameterless construction Setget, why is class still null
-
"The column vectors of a matrix whose determinant is equal to zero may not be linearly correlated"
-
PTA 7-1 string sorting (10 points)
-
Output the full arrangement of all 1 2 3 4 5 in dictionary order
-
How to create SQL trigger
-
Stm32tftlcd displays Chinese character scrolling
-
The format of the command in the CMD window is unclear
-
What does the class name in the class mean? It's not a variable or a member function
-
Seems to have started a program called [com,.] Process. But failed to stop it, which is likely to cause a memory leak. Stack trace for Thread:
-
Object oriented programming questions