Working with years in data struct

Hi.
I have a problem to solve this condition :
In a struct data are known the registration number of the person(consisting of 5 digits), the year, the day, and month of birth. We also know the number of people wich is n, the current month and day(wich are outside the struct). We should output the people that celebrated their birthday this year.
I want to know how to compare the years and how to work with them without any functions.
Here is a attempt but i doubt it could help :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;
struct elevi
{
 int registrationNR; 
 int year;
 int month; 
 int day;
}V[99];

int main(){
 int n,currentmonth,currentday;
 int i;
 int compday,compmonth,compyear;
  cin>>n>>currentday>>currentmonth; //nr de elevi 
  int currentmonth1 = currentmonth * 30;
  
 for(i=0;i<n;i++)
 {
     cin>>V[i].registrationNR>>V[i].day>>V[i].month>>V[i].year;
     compday  = V[i].day * 1;
     compmonth  = V[i].month * 30;
    compyear= V[i].year * 365;
    if(compday < currentday && compmonth < currentmonth1 && compyear< 737665)//wich is 2021 * 365
    {
        cout<< V[i].registrationNR<< " ";
    }
 }

    
}

can someone please help me understand or give me a hint

Last edited on
If you know the current month and day, then people who have celebrated their birthday have:

Birth months previous to the current month

OR

Birth months that are the same as the current month AND birth day-of-month the same as or previous to the current day-of-month.
can you show me an little example?
1
2
3
4
5
6
7
if ((birthMonth < currentMonth) ||
    ((birthMonth == currentMonth) &&
     (birthDayOfMonth <= currentDayOfMonth))
{
    // the person already celebrated a birthday this year
    // do whatever needs to be done
}


Beyond this help, I would be doing your homework for you.
doug4
thanks
Registered users can post here. Sign in or register to post.