bogdanNiculeasa

Untitled

Mar 1st, 2021
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. struct Address {
  7.     char street[50];
  8.     char city[50];
  9.     char number[10];
  10.     char county[50];
  11. };
  12.  
  13. struct Person {
  14.     char name[50];
  15.     int age;
  16.     char cnp[14];
  17.     Address address;
  18. };
  19.  
  20. int main() {
  21.     int numberOfPeople;
  22.     cout << "Cate persoane vrei sa citesti: " << endl;
  23.     cin >> numberOfPeople;
  24.     struct Person people[numberOfPeople];
  25.  
  26.     for(int i = 0; i < numberOfPeople; i++) {
  27.         cout << "Enter name: ";
  28.         cin >> people[i].name;
  29.         cout << "Enter age: ";
  30.         cin >> people[i].age;
  31.         cout << "Enter cnp: ";
  32.         cin >> people[i].cnp;
  33.         cout << "Enter address: ";
  34.         cout << "Enter the Street: " << endl;
  35.         cin >> people[i].address.street;
  36.         cout << "Enter the City: ";
  37.         cin >> people[i].address.city;
  38.         cout << "Enter the number: ";
  39.         cin >> people[i].address.number;
  40.         cout << "Enter the county: ";
  41.         cin >> people[i].address.county;
  42.     }
  43.  
  44.     for(int i = 0; i < numberOfPeople; i++) {
  45.         cout << "name: " << people[i].name << endl;
  46.         cout << "Age: " << people[i].age << endl;
  47.         cout << "Cnp: "<< people[i].cnp << endl;
  48.         cout << "Address: ";
  49.         cout << "Street: " << people[i].address.street << endl;
  50.         cout << "City: " << people[i].address.city << endl;
  51.         cout << "Number: " << people[i].address.number << endl;
  52.         cout << "County: " << people[i].address.county << endl;
  53.         cout << "-----------" << endl;
  54.     }
  55.  
  56.     return 0;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment