算法描述:
In contemporary business administration, mathematical tools are frequently applied in order to develop the business theory.
Numerical approaches are widely applied in the most of business characteristics because the business theories can be expressed in numerically.
Of course, the most of business theories can be expressed by just normal terms like a conservative way.
But, by using the mathematical methods, you may realize that more logical and clear process of theoretical development can be possible.
So let’s enjoy the math by Symmetric matrix
By using the first line with given input data, please output the matrix that is equal to its transpose
For example, the given input data is A B C D, and the Symmetric Matrix is as below
Time limit: 1 second
[Input]
In the first line, Input T, number of test case (T <= 10 )
In the second line, size of the matrix” N” is given (4 ≤ N ≤ 128, N must be High-radix exponent of 2)
In the third line, Space is separately given by number of N characteristics that is same with first line information
[Output]
Across the line for a given input of N to the first row, output the matrix that is diagonally symmetric matrix.
At this time, symmetric matrix must be same with the given example.
Each line data must be output separately as a empty
[I/O Example]
Input
2
4
B a & 2
8
1 2 3 4 A C B D
Output
B a & 2
a B 2 &
& 2 B a
2 & a B
1 2 3 4 A C B D
2 1 4 3 C A D B
3 4 1 2 B D A C
4 3 2 1 D B C A
A C B D 1 2 3 4
C A D B 2 1 4 3
B D A C 3 4 1 2
D B C A 4 3 2 1
分析:
利用异或
源码:
#include <iostream>
using namespace std;
int N;
char tmpChar[2];
char data[130];
int main(int argc, char** argv)
{
int test_case;
int T;
/*
The freopen function below opens input.txt file in read only mode, and afterward,
the program will read from input.txt file instead of standard(keyboard) input.
To test your program, you may save input data in input.txt file,
and use freopen function to read from the file when using cin function.
You may remove the comment symbols(//) in the below statement and use it.
Use #include<cstdio> or #include<stdio.h> to use the function in your program.
But before submission, you must remove the freopen function or rewrite comment symbols(//).
*/
freopen("input.txt", "r", stdin);
cin >> T;
for (test_case = 0; test_case < T; test_case++)
{
cin >> N;
for (int i = 0; i < N; i++) {
cin >> tmpChar;
data[i] = tmpChar[0];
}
/
/*
Implement your algorithm here.
The answer to the case will be stored in variable Answer.
*/
/
// Print the answer to standard output(screen).
for (int i = 0; i < N; i++)
{
int j;
for (j = 0; j < N; j++)
{
char c = data[i^j];
if (j == N - 1)
{
cout << c << endl;
}
else {
cout << c;
}
}
}
cout << endl;
}
return 0;//Your program should return 0 on normal termination.
}