#include <iostream>
using namespace std;
int main()
{
int MAXVAL = 11, COLS=3, display, nearest3;
if (MAXVAL % 3 > 0)
nearest3 = MAXVAL + (3 - MAXVAL % 3);
else
nearest3 = MAXVAL;
cout << "nearest3 is " << nearest3 << endl;
int ROWS = nearest3/COLS;
cout << "ROWS is " << ROWS << endl;
for(int r=1; r<=ROWS; r++) {
if(r+(nearest3/COLS)*2 <= MAXVAL)
cout << r << " " << r+(nearest3/COLS) << " " << r+(nearest3/COLS)*2 << endl ;
else if(r+(nearest3/COLS) <= MAXVAL)
cout << r << " " << r+(nearest3/COLS) << " " << endl ;
else
cout << r << " " << endl ;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpIAp7CiAgICBpbnQgTUFYVkFMID0gMTEsIENPTFM9MywgZGlzcGxheSwgbmVhcmVzdDM7CiAgICBpZiAoTUFYVkFMICUgMyA+IDApCiAgICAgICBuZWFyZXN0MyA9IE1BWFZBTCArICgzIC0gTUFYVkFMICUgMyk7CiAgICBlbHNlCiAgICAgICBuZWFyZXN0MyA9IE1BWFZBTDsKICAgICAgIAogICAgY291dCA8PCAibmVhcmVzdDMgaXMgIiA8PCBuZWFyZXN0MyA8PCBlbmRsOwogICAgaW50IFJPV1MgPSBuZWFyZXN0My9DT0xTOwogICAgY291dCA8PCAiUk9XUyBpcyAiIDw8IFJPV1MgPDwgZW5kbDsKICAgIAogICAgZm9yKGludCByPTE7IHI8PVJPV1M7IHIrKykgewogICAgCSAgICBpZihyKyhuZWFyZXN0My9DT0xTKSoyIDw9IE1BWFZBTCkKICAgIAkJICAgY291dCA8PCByIDw8ICIgIiA8PCByKyhuZWFyZXN0My9DT0xTKSA8PCAiICIgPDwgcisobmVhcmVzdDMvQ09MUykqMiA8PCBlbmRsIDsKICAgICAgICAgICAgZWxzZSBpZihyKyhuZWFyZXN0My9DT0xTKSA8PSBNQVhWQUwpCiAgICAJCSAgICAgICAgY291dCA8PCByIDw8ICIgIiA8PCByKyhuZWFyZXN0My9DT0xTKSA8PCAiICIgPDwgZW5kbCA7CiAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgciA8PCAiICIgPDwgZW5kbCA7CiAgICB9CglyZXR1cm4gMDsKfQo=