Last active
September 24, 2015 15:09
-
-
Save Michal-Szczepaniak/903dc340f2fcc3b24475 to your computer and use it in GitHub Desktop.
1 Sprawdzian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
//Pole trapezu | |
class trapez { | |
private: | |
int a,b,h; | |
public: | |
int pole() { | |
return ((a+b)*h)/2; | |
} | |
trapez() { | |
cout<<"Podaj a: "; | |
cin>>a; | |
cout<<"Podaj b: "; | |
cin>>b; | |
cout<<"Podaj h: "; | |
cin>>h; | |
} | |
~trapez() { | |
cout<<"\nObiekt został zniszczony"; | |
} | |
}; | |
int main() { | |
trapez obiekt; | |
cout<<obiekt.pole(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
//Róznica wieku | |
class czlowiek { | |
public: | |
string imie; | |
int wiek; | |
int wczytaj() { | |
cout<<"Podaj imie: "; | |
cin>>imie; | |
cout<<"Podaj wiek: "; | |
cin>>wiek; | |
} | |
}; | |
int oblicz(czlowiek os1, czlowiek os2) { | |
if(os1.wiek>os2.wiek) | |
return os1.wiek-os2.wiek; | |
else if(os2.wiek>os1.wiek) | |
return os2.wiek-os1.wiek; | |
} | |
int main() { | |
czlowiek os1,os2; | |
os1.wczytaj(); | |
os2.wczytaj(); | |
cout<<oblicz(os1,os2); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
//Nie było na sprawdzianie | |
// | |
//3 elementowa tablica z wiekiem maksymalnym i srednia | |
class ludz { | |
public: | |
string imie,nazwisko; | |
int wiek; | |
ludz() { | |
cout<<"Podaj imie: "; | |
cin>>imie; | |
cout<<"Podaj nazwisko: "; | |
cin>>nazwisko; | |
cout<<"Podaj wiek: "; | |
cin>>wiek; | |
} | |
}; | |
int main() { | |
ludz tab[3]; | |
int max=tab[0].wiek; | |
int id=0; | |
for(int i = 1; i < 3; i++) { | |
if(tab[i].wiek>max) { | |
max = tab[i].wiek; | |
id = i; | |
} | |
} | |
cout<<"\nNajstarszy jest "<<tab[id].imie<<" ma "<<tab[id].wiek<<" lat."; | |
int srednia=0; | |
for(int i = 0; i< 3; i++) { | |
srednia+=tab[i].wiek; | |
} | |
cout<<"Srednia wieku to: "<<srednia/3; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment