home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 March
/
Chip_2002-03_cd1.bin
/
chplus
/
cecko
/
CPP
/
VYPUSTKA.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1998-10-05
|
1KB
|
47 lines
// P⌐íklad: Programování v C++ na FJFI - ÇVUT
#pragma hdrfile="TCDEF.SYM" // pro urychlení p⌐ekladu
#include <iostream.h>
#include <stdarg.h>
int max(int n,...) {
va_list ap;
va_start(ap,n);
cout << "Maximum z çísel ";
int i=va_arg(ap,int);
cout << i;
for (int j=1;j<n;j++) {
int y=va_arg(ap,int);
if (j<(n-1)) cout << ", " << y; else cout << " a " << y << " je ";
if (y>i) i=y;
}
cout << i << "." << endl;
va_end(ap);
return i;
}
int min(int n,...) {
va_list ap;
va_start(ap,n);
cout << "Minimum z çísel ";
int i=va_arg(ap,int);
cout << i;
for (int j=1;j<n;j++) {
int y=va_arg(ap,int);
if (j<(n-1)) cout << ", " << y; else cout << " a " << y << " je ";
if (y<i) i=y;
}
cout << i << "." << endl;
va_end(ap);
return i;
}
int main() {
cout << "Start programu:" << endl;
int i=max(2,1,-1);
i=max(3,i,990,0);
i=min(2,1,-1);
i=min(3,i,990,0);
i=min(3.5,i/2,990.1,0); // zde to jiæ zaçne blbnout, protoæe 990.1 není typu int a ani se na int nep⌐evede
cout << "Konec programu, nebuâte smutní, mûæete si spustit znovu..." << endl << endl;
return 0;
}