Advertisement
neogz

STR - Knjiga unos-ispis

Sep 4th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. /*
  2.     11W - Zadatak 81.
  3. */
  4. #ifdef _MSC_VER
  5. #define _CRT_SECURE_NO_WARNINGS
  6. #endif
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. char crt[] = "\n--------------------------------------------------\n";
  11.  
  12. struct Knjiga {
  13.     char naziv[20];
  14.     char ISBN[20];
  15.     int cijena;
  16.     void ispis();
  17. };
  18. void Knjiga::ispis(){
  19.     cout << "NAZIV: \t\t" << naziv << endl;
  20.     cout << "ISBN: \t\t" << ISBN << endl;
  21.     cout << "CIJENA: \t" << cijena << " KM" << endl;
  22. }
  23.  
  24. int main() {
  25.    
  26.     const int max = 10;
  27.     Knjiga * niz = new Knjiga[max];
  28.    
  29.     cout << crt << "Unesite podatke za knjige: " << crt;
  30.     for (int i = 0; i < max; i++){
  31.         cout << "KNJIGA " << i + 1 << crt;
  32.        
  33.         cout << "Naziv -> ";
  34.         cin.getline(niz[i].naziv,20);
  35.  
  36.         cout << "ISBN -> ";
  37.         cin.getline(niz[i].ISBN, 20);
  38.  
  39.         cout << "CIJENA -> ";
  40.         cin >> niz[i].cijena;
  41.         cin.ignore();
  42.         cout << crt;
  43.     }
  44.  
  45.     cout << crt << "\t::KNJIGE::" << crt;
  46.     for (int i = 0; i <max; i++){
  47.         niz[i].ispis();
  48.     }
  49.  
  50.     delete[]niz;
  51.     niz = nullptr;
  52.  
  53.     system("pause>null");
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement