MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / solve

Function solve

CodeChef_problems/EVENM/Solution.cpp:24–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#define vi vector<ll>
23
24void solve()
25{
26 ll n;
27 cin >> n;
28 vector<vi> v(n, vi(n));
29 ll odd = 1;
30 ll even = 2;
31 bool flag = 1;
32 for (int i = 0; i < n; ++i)
33 {
34 for (int j = 0; j < n; ++j)
35 {
36 if (flag)
37 {
38 v[i][j] = odd;
39 odd += 2;
40 }
41 else
42 {
43 v[i][j] = even;
44 even += 2;
45 }
46 flag = !flag;
47 }
48 if (n % 2 == 0)
49 flag = !flag;
50 }
51
52 for (int i = 0; i < n; ++i)
53 {
54 for (int j = 0; j < n; ++j)
55 {
56 cout << v[i][j] << " ";
57 }
58 cout << endl;
59 }
60}
61
62int main()
63{

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected