[Code Jam 2022 Qualification Round 2022] Punched Cards

Punched Cards

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
#include <bits/stdc++.h>
using namespace std;
void punch(int c) {
cout<<"..";
for(int i = 0 ; i < c - 1; i++) cout<<"+-";cout<<"+"<<endl;
cout<<"..";
for(int i = 0 ; i < c - 1; i++) cout<<"|.";cout<<"|"<<endl;
}
void plane(int r, int c) {
for(int R = 0; R < r-1; R++) {
for(int i = 0 ; i < c; i++) cout<<"+-";cout<<"+"<<endl;
for(int i = 0 ; i < c; i++) cout<<"|.";cout<<"|"<<endl;
}
for(int i = 0 ; i < c; i++) cout<<"+-";cout<<"+"<<endl;
}
void solve(int r, int c) {
punch(c);
plane(r,c);
}

int main() {
int tc;
cin>>tc;
for(int i = 1; i <= tc; i++) {
int r, c;
cin>>r>>c;
cout<<"Case #"<<i<<":"<<endl;
solve(r,c);
}
return 0;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/04/02/PS/Google/punched-cards/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.