![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Other Questions
greatbear_us
这个作者很懒,什么都没留下…
展开
-
Rounded Numbers
Write code to round numbers? #include #include int roundedNumber(double num); int main() { int num = roundedNumber(5.56); printf("%d\n", num); return 0; } int roundedNumber(double num)原创 2013-05-11 09:34:44 · 358 阅读 · 0 评论 -
Factorial of a number
#include #include int factorial(int n); int main() { int rs = fact(5); printf("%d\n", rs); return 0; } int factorial(int n){ if(n == 1) return 1; return factorial(n-1)原创 2013-05-11 09:47:17 · 388 阅读 · 0 评论 -
Greatest Common Divisor(GCD) of Two Numbers
#include #include int gcd(int a, int b); int gcdRecursive(int, int); int gcdRecursiveHelper(int, int); void swap(int* a, int* b); int main() { int a = gcd(56,12); int b = gcdRecursive(18, 1原创 2013-05-11 10:05:57 · 425 阅读 · 0 评论 -
Palindrome
Check if a string is palindrome. #include #include int palindrome(char str[]); int main() { char str[] ="abcba"; printf("%c\n",str[5]); if(palindrome(str)){ printf("is palindr原创 2013-05-12 01:16:00 · 324 阅读 · 0 评论 -
Fibonacci Numbers
#include #include int fabonicciRecursive(int); int fabonicci(int); int main() { int rs = fabonicci(5); int rs2 = fabonicciRecursive(5); printf("%d\n", rs); printf("%d\n", rs2);原创 2013-05-11 09:51:16 · 338 阅读 · 0 评论 -
Reverse a positive number
int reverseNum(int num){ int result = 0; int tmp; while(num > 0){ tmp = num % 10; result = 10 * result + tmp; num /= 10; } return result; }原创 2013-05-12 12:49:51 · 378 阅读 · 0 评论 -
Implement Your Own sizeof
#define my_sizeof(type) (char *)(&type+1)-(char*)(&type)原创 2013-05-12 12:37:41 · 327 阅读 · 0 评论 -
power of 2 or not
int ispowerof2(unsigned int x) { return x && !(x & (x - 1)); } Note that the bit pattern of a power of two is of the form 10...0 and that of a number just one less is 011...1.原创 2013-05-12 01:34:34 · 623 阅读 · 0 评论