// do_while_max.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();

int _tmain(int argc, _TCHAR* argv[])
{
	unsigned i, x, max, max1, max2, pocet_max, suma_x;

	max = 0;
	suma_x = 0;
	pocet_max = 0;
	i = 0;
	cout << "\nZadavajte kladne cele cisla, pokym ich sucet nepresiahne cislo 500.\n";
	do {
		cout << "x = ";
		cin >> x;
		if (x > max) {
			max = x;
			max1 = max2 = i;
			pocet_max = 1;
		}
		else {
			if (x == max) {
				pocet_max++;
				max2 = i;
			}
		}
		suma_x += x;
		i++;
	} while (suma_x <= 500);

	cout << "\nMaximum " << max << " sa prvy krat vyskytlo na " << max1 + 1 
		<< "-tom mieste" << "\na posledny raz na " << max2 + 1 
		<< "-tom mieste, celkovo " << pocet_max << "-krat.";

	my_getch();
	return 0;
}

void my_getch()
{
#ifdef _WIN32
	_getch();
#else
	cout << endl;
#endif
}