Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <ctime>
- using namespace std;
- const int N = 3;
- const int PREZZO_MAX = 200;
- struct Tipolibro {
- string titolo;
- string autore;
- int anno_di_edizione;
- int prezzo;
- };
- int main(){
- srand (time(NULL));
- Tipolibro Type;
- Tipolibro libri[N] = {}; //array di libri Tipolibro
- int prezzi[N] = {};
- int anni_ed[N] = {};
- int somma_prezzi = 0;
- //riempio l'array dei libri
- for (int i = 0; i < N; i++){
- cout << "Inserire titolo libro: ";
- cin >> Type.titolo;
- // cout << "TITOLO: " << Type.titolo << endl; //debug
- cout << "Inserire autore libro: ";
- cin >> Type.autore;
- // cout << "AUTORE: " << Type.autore << endl; //debug
- cout << "Inserire anno di edizione libro: ";
- cin >> Type.anno_di_edizione;
- // cout << "ANNO: " << Type.anno_di_edizione << endl; //debug
- int prezzo_random = rand()%PREZZO_MAX;
- Type.prezzo = prezzo_random;
- cout << "PREZZO: " << Type.prezzo << endl; //debug
- libri[i] = Type;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement