Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdarg.h>
- #include <iostream>
- #include <math.h>
- using namespace std;
- double var(double num, ...) {
- double sum = 0, t;
- va_list argptr;
- va_start(argptr, num);
- for (int n = 0; n < num; n++) {
- t = va_arg(argptr, double);
- if ((int)t & 1) sum += t; else sum -= t;
- }
- va_end(argptr);
- return sum;
- }
- int main() {
- system("color f0");
- double result;
- result = var(7, 1.4, 2.2, 3.6, 4.5, 5.5, 6, 7); // первая цифра указывает кол-во введенных элементов
- cout << "Summa: " << result;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement