// fields_as_parameters.cpp
//
#ifdef _WIN32
	#include <tchar.h>
	#include <conio.h>
#elif (defined __linux__) || (defined _AIX) || (defined __APPLE__)
	typedef char _TCHAR;
	#define _tmain main
#endif

#include <stdio.h>
#include <iostream>
using namespace std;

void my_getch();
void function4(const unsigned, const int[], int[]);
void function5(const unsigned, const unsigned, const int[][20], int[][20]);

int _tmain(int argc, _TCHAR* argv[])
{
	unsigned m, n, i, j, k;
	int A[100], B[100], C[20][20], D[20][20];

	cout << "\nZadajte pocet cisel: ";
	cin >> n;
	for (i = 0; i < n; i++) {
		cout << "A[" << i << "] = ";
		cin >> A[i];
	}
	for (i = 0; i < 5; i++) {
		function4(n, A, B);
		for (j = 0; j < n; j++)
			A[j] = B[j];
	}
	cout << "\n5x pouzita inkrementacna function4 dava vysledky:\n\n";
	for (i = 0; i < n; i++)
		cout << "B[" << i << "] = " << B[i] << endl;

	cout << "\nZadajte rad matice C!" << endl;
	cout << "Pocet riadkov je ";
	cin >> m;
	cout << "Pocet stlpcov je ";
	cin >> n;
	cout << "Zadajte prvky celociselnej matice C!" << endl << endl;
	for (i = 0; i < m; i++)
		for (j = 0; j < n; j++) {
			cout << "    ";
			cout << "C[" << i << "][" << j << "]=";
			cin >> C[i][j];
		}
	cout << endl << "Zadali ste nasledujucu maticu." << endl;
	cout << endl << "C:";
	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++)
			printf("%4d", C[i][j]);
		cout << endl << "  ";
	}

	for (i = 0; i < 5; i++) {
		function5(m, n, C, D);
		for (j = 0; j < m; j++)
			for (k = 0; k < n; k++)
				C[j][k] = D[j][k];
	}
	cout << "\n5x pouzita inkrementacna function5 dava vysledky:\n";
	cout << endl << "D:";
	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++)
			printf("%4d", D[i][j]);
		cout << endl << "  ";
	}

	my_getch();
	return 0;
}
//---------------------------------------------------------------------------
void my_getch()
{
#ifdef _WIN32
	_getch();
#else
	cout << endl;
#endif
}
//---------------------------------------------------------------------------
void function4(const unsigned pocet, const int pole1[], int pole2[])
{                    // polia pouzite ako parametre funkcie
	unsigned i;       // pole1 je iba vstupny parameter
							// pole2 moze byt vstupny aj vystupny parameter
	for (i = 0; i < pocet; i++)
		pole2[i] = pole1[i] + 1;
}
//---------------------------------------------------------------------------
void function5(const unsigned m, const unsigned n, const int pole1[][20],
	int pole2[][20])
{                      // polia pouzite ako parametre funkcie
	unsigned i, j;      // pole1 je iba vstupny parameter
							  // pole2 moze byt vstupny aj vystupny parameter
	for (i = 0; i < m; i++)
		for (j = 0; j < n; j++)
			pole2[i][j] = pole1[i][j] + 1;
}
//---------------------------------------------------------------------------