Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdarg.h>
- #include <locale.h>
- void sum(int i,...)
- {
- float y=0;
- va_list a;
- va_start (a,i);
- for( ;i>0;i--)
- {
- int x = va_arg(a, int);
- y+=1/float(x);
- }
- va_end (a);
- printf("sum = %f",y);
- }
- int main()
- {
- int i;
- setlocale(LC_ALL,"rus");
- printf("Введите количество слагаемых\nn = ");
- scanf("%i",&i);
- sum(i,1,2,3,4,5,6,7,8,9);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement