DELETED
#include <windows.h>
#include <stdio.h>
#include "..\m_apm.h"
// Syntax: MAX x1 x2 ... xk
// Change -1 to 1 for MIN (see below)
INT main ( INT argc, LPSTR *argv )
{
INT index_of_max = 1;
M_APM n[2] = { m_apm_init(), m_apm_init() };
INT imax = 0, itest = 1;
m_apm_set_string(n[imax], argv[1]);
for ( INT i=2; i<argc; i++ )
{
m_apm_set_string(n[itest], argv[i]);
if ( m_apm_compare(n[imax], n[itest]) == -1 ) // change to 1 for MIN
{
index_of_max = i;
imax = itest;
itest = 1 - itest;
}
}
m_apm_free(n[0]);
m_apm_free(n[1]);
printf("%s\r\n", argv[index_of_max]);
}
// Syntax: MAX x1 x2 ... xk
INT main ( INT argc, LPSTR *argv )
{
if ( argc < 2 ) return 0;
INT index_of_max = 1, imax = 0, itest = 1, i;
MAPM m[2] = {argv[1], 0};
for ( i=2; i<argc; i++ )
{
m[itest] = argv[i];
if ( m[itest] > m[imax] ) // use < for MIN
{
index_of_max = i;
imax = itest; // this flip-flopping avoids the somewhat costly
itest = 1 - itest; // assignment of the test MAPM to the max MAPM
}
}
printf("%s\r\n", argv[index_of_max]);
return 0;
}