Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
using namespace std; class Hotel { private: char ime[21]; int broj_na_zafeteni_sobi; int zvezdi; int vkupen_broj_na_sobi; public: Hotel() { } Hotel(const char *c, int br_z_s, int z, int v_s) { strcpy(ime, c); broj_na_zafeteni_sobi = br_z_s; zvezdi = z; vkupen_broj_na_sobi = v_s; } ~Hotel() { } void input() { cin >> ime >> broj_na_zafeteni_sobi >> zvezdi >> vkupen_broj_na_sobi; } void set_zafateni(int z) { if(z > vkupen_broj_na_sobi) { cout << "ne moze da ima volku zafateni sobi" << endl; return; } broj_na_zafeteni_sobi = z; } int get_zafateni() const { return broj_na_zafeteni_sobi; } int get_vkupno() const { return vkupen_broj_na_sobi; } int get_slobodni() const{ return vkupen_broj_na_sobi - broj_na_zafeteni_sobi; } int get_zvezdi() const { return zvezdi; } const char* get_ime() const { return ime; } Hotel& operator -= (int z) { broj_na_zafeteni_sobi += z; return *this; } bool operator > (const Hotel &h) { return get_slobodni() > h.get_slobodni(); } }; void pecati(Hotel niza[], int n) { for(int i = 0; i < n; i++) { cout << niza[i].get_ime() << " " << niza[i].get_zvezdi() << " " << niza[i].get_zafateni() << " " << niza[i].get_vkupno() << endl; } } int main() { Hotel niza[5]; for(int i = 0; i < 3; i++) { niza[i].input(); } niza[0] -= 1; niza[1] -= 2; niza[2] -= 3; pecati(niza, 3); return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)