mirror of
https://github.com/szymon-jozef/ZUT-notatki.git
synced 2026-10-28 11:10:38 +01:00
notatki
This commit is contained in:
30
uczelnia/2_semestr/programowanie/laby/lab2/zad9.cpp
Normal file
30
uczelnia/2_semestr/programowanie/laby/lab2/zad9.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
double srednia(int a, int b, int c) { return (double)(a + b + c) / 3; }
|
||||
|
||||
double srednia(int a, int b) { return (double)(a + b) / 2; }
|
||||
|
||||
double srednia(int a, int b, int c, int d) {
|
||||
return (double)(a + b + c + d) / 4;
|
||||
}
|
||||
|
||||
bool czyZaliczyl(double wynik, double prog = 3.0) { return wynik >= prog; }
|
||||
|
||||
int main() {
|
||||
int a, b, c;
|
||||
cout << "Podaj a: ";
|
||||
cin >> a;
|
||||
cout << "Podaj b: ";
|
||||
cin >> b;
|
||||
cout << "Podaj c: ";
|
||||
cin >> c;
|
||||
|
||||
double avg = srednia(a, b, c);
|
||||
cout << "Twoja średnia wynosi: " << avg << endl;
|
||||
if (czyZaliczyl(avg)) {
|
||||
cout << "Zaliczyłeś, brawo!" << endl;
|
||||
} else {
|
||||
cout << "Nie zaliczyłeś :(" << endl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user