真·签到题
Time Limit: 1000 ms Memory Limit: 65536 KiB
Submit Statistic
Problem Description
现在有一个n行m列的格子,小F从左上角出发向右出发,然后以蛇形遍历这个格子,请输出小F的路径。
Input
首先输入一个T表示有T组输入,每组输入第一行为n,m,接下来有n行,每行m个数字,代表一个n*m的矩阵。
0 < T <= 10 , 0 < n <= 50, 0 < m <= 50.
Output
请输出小F的路径。
Sample Input
复制代码
1
2
3
4
51 3 3 1 2 3 4 5 6 7 8 9
Sample Output
复制代码
11 2 3 6 5 4 7 8 9
Hint
Source
这个题的难度就是对输出空格和换行的要求,细节把握好了就没问题了。
代码(c++):
复制代码
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int t; cin>>t; while(t>0) { int n,m; cin>>n>>m; int a[100][100]; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cin>>a[i][j]; } } for(int i=1; i<=n; i++) { if(i%2==0) { if(i==n) { for(int j=m; j>0; j--) { if(j==1) { cout<<a[i][j]<<endl; } else { cout<<a[i][j]<<" "; } } } else { for(int j=m; j>0; j--) { cout<<a[i][j]<<" "; } } } else { if(i==n) { for(int j=1; j<=m; j++) { if(j==m) { cout<<a[i][j]<<endl; } else { cout<<a[i][j]<<" "; } } } else { for(int j=1; j<=m; j++) { cout<<a[i][j]<<" "; } } } } t--; } return 0; }
最后
以上就是可耐冬天最近收集整理的关于真*签到题(SDUTACM第二次选拔)的全部内容,更多相关真*签到题(SDUTACM第二次选拔)内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复