// Flip.cpp
#include <iostream>
#include "include/S.h"
using namespace std;
int main()
{
static int width=S::sw();
static int height=S::sh(width);
int horizontal;
int *position;
int source[width*height];
int dest[width*height];
cout << "\n\n";
for(int x = 0; x < width*height; x++)
source[x]=x;
S::print_rect(width, height, &source[0]);
cout << "\nFlip horizontally?"
<< "\nEnter 1 for true, 0 for false: ";
cin >> horizontal;
cout << endl;
if(horizontal)
{
for(int h = 0; h < height; ++h)
{
position=&source[h*width];
for(int w = width - 1, i = 0; w > -1; --w, ++i)
dest[h*width + i] = position[w];
}
}
else
{
for(int h = height - 1, i = 0; h > -1; --h, ++i)
{
position=&source[h*width];
for(int w = 0; w < width; ++w)
dest[i*width+w] = position[w];
}
}
S::print_rect(width, height, &dest[0]);
cout << endl;
}