C and pointer (pointers on C) -- Chapter 7: function (ii) exercises

Source: Internet
Author: User

This is a classic topic.

1. Hermite Polynomials

2. Calculate the maximum common divisor of two integers.

3. atoi

4. Use of variable parameter lists

Here are the specific questions:

Please see http://download.csdn.net/download/wangpegasus/5701765

1,

int hermite(int n, int x){if (n < 1){return 1;}elseif (n == 1){return 2 * x;}else{return 2 * x * hermite(n-1, x) - 2 * (n-1) * hermite(n-2, x);}}
2,
int gcd(int M, int N){if (M <= 0 || N <= 0){return 0;}elseif ( M%N == 0 ){return N;}else{return gcd(N, M%N);}}

3,
int ascii_to_integer(char *string){int result;result = 0;while (*string >= '0' && *string <= '9'){result *= 10;result += *string - '0';string++;}while (*string != '\0'){*string <= '0'|| *string >= '9';result = 0;}return result;}

4,

#include "stdarg.h"int max( int n_value, ...){va_list va_arg;int max_value = 0;va_start(va_arg, n_value);for (int i = 0; i < n_value; i++){if (max_value < va_arg(va_arg, int)){max_value = va_arg(va_arg, int);}}va_end(va_arg);return max_value;}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.