Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cstdlib>
- using namespace std;
- float a,b,c,d,e,m,srednia,z;
- int main()
- {
- cout << "Podaj 5 liczb rozdzielonuch spacjami: ";
- cin >> a >> b >> c >> d >> e;
- srednia = (a+b+c+d+e) /5;
- cout << "Srednia wynosi: " << srednia << endl;
- z=a;
- m =(fabs(srednia-a));
- if ((fabs(srednia-b))<m)
- {
- m=fabs(srednia-b);
- z=b;
- }
- if ((fabs(srednia-c))<m)
- {
- m=fabs(srednia-c);
- z=c;
- }
- if ((fabs(srednia-d))<m)
- {
- m=fabs(srednia-d);
- z=d;
- }
- if ((fabs(srednia-e))<m)
- {
- m=fabs(srednia-e);
- z=e;
- }
- cout << "Najblizej sredniej to: " << z << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement