2022-02-13 14:35:34 -05:00
|
|
|
typedef unsigned long va_list;
|
|
|
|
#define va_start(list, arg) ((list) = (unsigned long)&arg)
|
|
|
|
#define va_arg(list, type) (*((type *)(list += ((sizeof(type) + 7) & 0xfffffffffffffff8))))
|
|
|
|
#define va_end(list)
|
|
|
|
|
|
|
|
int sum(int n, ...) {
|
|
|
|
va_list args;
|
|
|
|
int i;
|
|
|
|
int total = 0;
|
|
|
|
va_start(args, n);
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
total += va_arg(args, int);
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2022-02-12 23:04:53 -05:00
|
|
|
long factorial(long x) {
|
2022-02-13 12:24:19 -05:00
|
|
|
if (x == 0) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return x * factorial(x-1);
|
|
|
|
}
|
2022-02-12 21:27:57 -05:00
|
|
|
}
|
|
|
|
|
2022-02-12 23:04:53 -05:00
|
|
|
long fibonacci(long x) {
|
2022-02-13 11:24:30 -05:00
|
|
|
return x > 0 ?
|
|
|
|
x > 1 ?
|
2022-02-12 23:04:53 -05:00
|
|
|
fibonacci(x-1) + fibonacci(x-2)
|
|
|
|
: 1
|
|
|
|
: 0;
|
2022-02-12 21:27:57 -05:00
|
|
|
}
|
|
|
|
|
2022-02-13 12:24:19 -05:00
|
|
|
long gcd(long a, long b) {
|
|
|
|
while (a != 0) {
|
|
|
|
long temp = a;
|
|
|
|
a = b % a;
|
|
|
|
b = temp;
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2022-02-13 12:51:21 -05:00
|
|
|
int f() {
|
|
|
|
lb: goto lb;
|
|
|
|
}
|
|
|
|
|
2022-02-13 14:24:38 -05:00
|
|
|
int main(int argc, char **argv) {
|
2022-02-13 14:35:34 -05:00
|
|
|
return sum(3, -100, 200, -300);
|
2022-02-09 22:44:27 -05:00
|
|
|
}
|
2022-02-12 21:27:57 -05:00
|
|
|
|