#include <string>
#include <iostream>
using namespace std;
const int HEIGHT = 2;
const int WIDTH = 3;
void myprint(double an_array[][WIDTH]) {
for (int i = 0; i < HEIGHT; i++) {
if (0 == i) {
cout << "{ {";
}
else {
cout << " {";
}
for (int j = 0; j < WIDTH; j++) {
if (WIDTH - 1 == j) {
cout << an_array[i][j] << "}";
}
else {
cout << an_array[i][j] << ", ";
}
}
if (HEIGHT - 1 == i) {
cout << " }" << endl;
}
else {
cout << "," << endl;
}
}
}
int main() {
const int HEIGHT = 2;
const int WIDTH = 3;
double values[HEIGHT][WIDTH] = { { 2, 3, 4 }, { 7, 8, 9 } };
cout << "Beginning ...\n\n";
cout << "Original:\n\n";
for (int i = 0; i < HEIGHT; i++) {
if (0 == i) {
cout << "{ {";
}
else {
cout << " {";
}
for (int j = 0; j < WIDTH; j++) {
if (WIDTH - 1 == j) {
cout << values[i][j] << "}";
}
else {
cout << values[i][j] << ", ";
}
}
if (HEIGHT - 1 == i) {
cout << " }" << endl;
}
else {
cout << "," << endl;
}
}
cout << "Modifiying:\n\n";
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < WIDTH; j++) {
if ((0 != j) && (0 != i)) {
values[i][j] = values[i][j] + values[i - 1][j - 1];
}
}
}
cout << "Modified:\n\n";
myprint(values);
cout << "\n...end\n";
system("pause");
return 0;
}
Back to top