Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication7.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "cstdlib"
- #include "iostream"
- #include "math.h"
- using namespace std;
- int main()
- {
- cin.clear();
- cin.sync();
- float a, b, c, d, e, x;
- float najb;
- cout << "Podaj 5 liczb: ";
- cin >> a >> b >> c >> d >> e;
- cout << a<<endl << b<<endl << c<<endl << d<<endl << e<<endl;
- float s = 0;
- s = (a + b + c + d + e) / 5;
- cout << "Srednia to:" << s << endl;
- {
- x = fabs(s - a);
- s = a;
- }
- if (fabs(s - b) < x)
- {
- x = fabs(s - b);
- najb = b;
- }
- if (fabs(s - c) < x)
- {
- x = fabs(s - c);
- najb = c;
- }
- if (fabs(s - d) < x)
- {
- x = fabs(s - d);
- najb = d;
- }
- if (fabs(s - e) < x)
- {
- x = fabs(s - e);
- najb = e;
- }
- cout << "Liczba najblizsza sredniej to : " << najb;
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement