zoukankan      html  css  js  c++  java
  • sum_series() 求一列数的指定个数的数和(5个数字的和)

     1 #include <stdio.h>
     2 #include <stdarg.h>
     3 /*用sum_series() 求一列数的指定个数的数和(5个数字的和)*/
     4 double sum_series(int num, ...);
     5 
     6 int main()
     7 {
     8     double s;
     9     s = sum_series(5, 0.5, 0.25, 0.125, 0.06254, 2.0);
    10     printf("Sum of series is %2.8f.
    ", s);
    11     return 0;
    12 }
    13 
    14 double sum_series(int num, ...)
    15 {
    16     double sum= 0.0, t;
    17     va_list a;
    18     va_start(a, num);
    19     for(; num; num--)
    20     {
    21         t= va_arg(a, double);
    22         sum= sum+ t;
    23     }
    24     va_end(a);
    25     return sum;
    26 }
  • 相关阅读:
    【心情】codeforces涨分啦!
    redis
    rabbitmq
    lucene
    MongoDB
    负载均衡
    分布式存储
    Memcache
    websocket
    Remoting
  • 原文地址:https://www.cnblogs.com/xrhou12326/p/3305372.html
Copyright © 2011-2022 走看看