Advertisement
Guest User

Untitled

a guest
Apr 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. struct NOTE{
  7.     char * NAME;
  8.     char * TELE;
  9.     int BDAY[3];
  10. };
  11.  
  12. class Data{
  13. public:
  14.     NOTE * BLOCKNOTE;
  15.  
  16.     Data(){
  17.         BLOCKNOTE = new NOTE[8];
  18.     }
  19.  
  20.     NOTE get(int num){
  21.         return BLOCKNOTE[num];
  22.     }
  23.  
  24.     void set(int num, char * NAME, char * TELE, int day, int month, int year){
  25.         BLOCKNOTE[num].NAME = NAME;
  26.         BLOCKNOTE[num].TELE = TELE;
  27.         BLOCKNOTE[num].BDAY[0] = day;
  28.         BLOCKNOTE[num].BDAY[1] = month;
  29.         BLOCKNOTE[num].BDAY[2] = year;
  30.     }
  31.  
  32.     void enter_data(){
  33.         cout << "Enter 8 elements: \n";
  34.         for (int i = 0; i < 8; i++){
  35.             cout << "[+] Element #" << i<< "\n";
  36.             cout << "Name: ";
  37.             cin >> BLOCKNOTE[i].NAME;
  38.             cout << "\nPhone: ";
  39.             cin >> BLOCKNOTE[i].TELE;
  40.             cout << "\nBirthday: Day:";
  41.             cin >> BLOCKNOTE[i].BDAY[0];
  42.             cout << ", month: ";
  43.             cin >> BLOCKNOTE[i].BDAY[1];
  44.             cout << ", year: ";
  45.             cin >> BLOCKNOTE[i].BDAY[2];
  46.         }
  47.     }
  48.  
  49.     void find_birthday(int month){
  50.         int count = 0;
  51.         for (int i = 0; i < 8; i++){
  52.             if (BLOCKNOTE[i].BDAY[1] == month){
  53.                 count++;
  54.                 cout << "Name: " << BLOCKNOTE[i].NAME << "Birthday: " << BLOCKNOTE[i].BDAY[0] << "." << BLOCKNOTE[i].BDAY[1] << "." << BLOCKNOTE[i].BDAY[2];
  55.                 cout << " Phone: " << BLOCKNOTE[i].TELE << "\n";
  56.             }
  57.         }
  58.  
  59.         if (count == 0)
  60.             cout << "Nothing found.\n";
  61.     }
  62. };
  63.  
  64. void main(){
  65.     Data data;
  66.  
  67.     data.enter_data();
  68.     data.find_birthday(2);
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement