Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <locale.h>
  5.  
  6. int main()
  7. {
  8.     setlocale (LC_ALL, "rus");
  9.     int x,n=0;
  10.     float sum=1,mul=1;
  11.     printf("Введите числа, признак конца ввода — 0:");
  12.     do
  13.     {
  14.         scanf("%d",&x);
  15.         n += 1;
  16.  
  17.         if(x>0)
  18.             sum+=x;
  19.         if(n%2!=0)
  20.             mul*=x;
  21.  
  22.     }while (x!=0);
  23.  
  24.    printf("Сумма положительных: %.2f",sum);
  25.    printf("Произведение нечётных: %.2f",sum);
  26.    return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement