#include <iostream>
#include <string>
using namespace std;
int main()
{
char array[7][256];
int number;
cout << "Specify seven numbers\n";
for (int i = 0; i < 7; i++)
{
cin >> number;
if (number < 0)
number = -number;
string numerical = to_string(number); // C++11 feature
for (string::size_type j = 0; j < numerical.size(); j++)
array[i][j] = numerical[j];
array[i][numerical.size()] = '\0';
}
for (int i = 0; i < 7; i++)
{
char *ch = array[i];
while (*ch != '\0')
{
if (*ch == '9')
*ch = '0';
++ch;
}
}
char *repl = 0;
for (int i = 0; i < 7; i++)
{
for (int j = 0; array[i][j]; j++)
{
if ((i + j) % 2)
array[i][j] = *repl;
else
repl = &array[i][j];
}
}
for (int i = 0; i < 7; i++)
{
for (int j = 0; array[i][j]; j++)
{
cout << array[i][j] << '\t';
}
cout << '\n';
}
return 0;
}
Comments
Leave a comment