-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.cc
More file actions
60 lines (36 loc) · 1.11 KB
/
loop.cc
File metadata and controls
60 lines (36 loc) · 1.11 KB
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
#include <iostream>
#include <iomanip>
using namespace std;
//-----------------------------------------------------------------------------
void cell( int r, int q ) {
cout << "{ " << right << setw( 2 ) << r
<< "," << right << setw( 2 ) << q
<< " }";
}; // end cell
//-----------------------------------------------------------------------------
void row( int size, int offset, int R ) {
// if ( ( R % 2 ) != 0 ) cout << " ";
cout << "{ ";
for ( int Q = 0; Q < size; ++Q ) {
cell( Q + offset, R );
if ( Q < ( size - 1 ) ) cout << ", ";
}; // for loop
cout << " }";
if ( R < ( size - 1 ) ) cout << "," << endl;
}; // end row
//-----------------------------------------------------------------------------
void loop() {
int size = 10;
int other = 0;
cout << "{ ";
for ( int R = 0; R < size; ++R ) {
row( size, other, R );
if ( ( R % 2 ) != 0 ) --other;
}; // end loop
cout << " }" << endl;
}; // end loop
//-----------------------------------------------------------------------------
int main( int, char*[] ) {
loop();
return 0x0;
}; // end main