This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2025-04-13 21:48:15 +03:00

40 lines
611 B
C
Executable File

#include <stdio.h>
#include <stdint.h>
#include <errno.h>
#include <stdlib.h>
#include <math.h>
enum
{
PRCN = 10000,
};
int
main(int argc, char *argv[])
{
long double a = 0;
for (int i = 1; i < argc; i++) {
char *p;
errno = 0;
long double val = strtod(argv[i], &p);
if (*p || errno || argv[i] == p) {
return 1;
}
if (i == 1) {
a = val * PRCN;
} else {
a = round(a * (100.L + val) / 100.L);
}
}
if (argc == 1) {
return 1;
}
printf("%.4Lf\n", a / PRCN);
return 0;
}