if, while, do
This commit is contained in:
parent
f6ee9bfa66
commit
70523ba1bb
2 changed files with 87 additions and 29 deletions
47
05/main.c
47
05/main.c
|
@ -1,6 +1,9 @@
|
|||
long factorial(long x) {
|
||||
return x > 0 ? x * factorial(x - 1)
|
||||
: 1;
|
||||
if (x == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return x * factorial(x-1);
|
||||
}
|
||||
}
|
||||
|
||||
long fibonacci(long x) {
|
||||
|
@ -11,28 +14,22 @@ long fibonacci(long x) {
|
|||
: 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
float f = 3.7;
|
||||
int i = 37;
|
||||
f--;
|
||||
++i;
|
||||
--f;
|
||||
++f;
|
||||
f++;
|
||||
--i;
|
||||
f--;
|
||||
++i;
|
||||
--f;
|
||||
++f;
|
||||
f++;
|
||||
--i;
|
||||
f--;
|
||||
++i;
|
||||
--f;
|
||||
++f;
|
||||
f++;
|
||||
--i;
|
||||
|
||||
return f;
|
||||
long gcd(long a, long b) {
|
||||
while (a != 0) {
|
||||
long temp = a;
|
||||
a = b % a;
|
||||
b = temp;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
double f = 1;
|
||||
int exp = 0;
|
||||
do {
|
||||
f /= 2;
|
||||
++exp;
|
||||
} while (f);
|
||||
return exp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue