一道笔试题
一道笔试题
Ivoripuion前几天华为实习生的一道笔试题,可能是我投安全岗的原因,编程题比较简单,记录下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using namespace std;
int main() {
int num;
cin >> num;
char **p = new char*[num];
for (int i = 0; i < num; i++)
p[i] = new char[9];
for (int i = 0; i < num; i++) {
for (int j = 0; j < 9; j++) {
char tmp;
cin >> tmp;
p[i][j] = tmp;
}
}
for (int i = 0; i < num; i++) {
if ((p[i][0]-48)) {
for (int j = 1; j < 9; j++)
cout << p[i][j];
}
else if(!(p[i][0]-48)){
for (int j = 8; j >= 1; j--)
cout << p[i][j];
}
cout<<" ";
}
}