Advertisement
Cieslin

PPMinMax

Nov 20th, 2017
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. // Nauka_1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <conio.h>
  6. #include <Windows.h>
  7.  
  8. int main()
  9. {
  10.     while (true)
  11.  
  12.     {
  13.         double suma = 0;
  14.         double n = 0;
  15.         double max = 0;
  16.         double min = 0;
  17.         double srednia = 0;
  18.         while (true)
  19.         {
  20.  
  21.             double liczba;
  22.  
  23.             printf("Podaj liczbe ");
  24.             scanf_s("%lf", &liczba);
  25.             if (liczba > max)
  26.                 max = liczba;
  27.             if (liczba < min)
  28.                 min = liczba;
  29.             while (liczba == 0)
  30.             {
  31.                 printf("Suma = %lf \n", suma);
  32.                 printf("Srednia = %lf\n", srednia);
  33.                 printf("Max = %lf\n", max);
  34.                 printf("Min = %lf\n", min);
  35.                 _getch();
  36.                 suma = 0;
  37.                 n =-1;
  38.                 break;
  39.             }
  40.  
  41.             suma += liczba;
  42.             n++;
  43.             srednia = suma / n;
  44.  
  45.  
  46.         }
  47.  
  48.     }
  49.    
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement