Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Класи - Пример */
- #include <iostream>
- using namespace std ;
- class Square {
- private:
- int a , b , c;
- public:
- Square (int aa , int bb , int cc ) {
- a = aa ;
- b = bb ;
- c = cc ;
- }
- ~Square() {
- }
- int area () {
- return 2 * (a * b + a * c + b * c );
- }
- int volume () {
- return a * b * c ;
- }
- };
- int main () {
- Square object(10 , 15 , 20) ;
- cout << "Area is: " << object.area () << endl ;
- cout << "Volumenot e: " << object.volume () << endl ;
- return 0;
- }
- /* Класи - Задача 1 */
- #include <iostream>
- #include <cmath>
- using namespace std ;
- class Tri {
- private:
- int a , b , c;
- public:
- Tri(int aa , int bb , int cc ) {
- a = aa ;
- b = bb ;
- c = cc ;
- }
- ~Tri() {
- }
- int perimetar() {
- return a+b+c;
- }
- int ploshtina() {
- float s = ( a + b + c) / 2;
- return sqrt(s * ( s - a) * (s - b) * (s - c));
- }
- };
- int main () {
- int x,y,z;
- cin >> x >> y >> z;
- Tri object(x,y,z);
- cout << "Perimetarot is: " << object.perimetar() << endl ;
- cout << "Ploshtinata is: " << object.ploshtina() << endl ;
- return 0;
- }
- /* Класи - Задача 2 */
- /* Класи - Задача 3 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement