I was trying to solve an exercise which asks you to find whether an event is held at a given year. The year is given through user input. The event is held every 4 years, beginning with/firstly held at year 0. The catch is that you can't use loops because we hadn't learned them yet. I solved the exercise but I was wondering if there was any other way to solve it. My code is down below.
int x;
cin>>x;
if(x%2==0)
{
if((x<10)&&(x%10==4,8)&&(x>=0))
{
cout<<"Event";
}
else
if((x/10%2!=0)&&(x%10!=4,8))
{
cout<<"Event";
}
}
else
cout<<"No event";
Aucun commentaire:
Enregistrer un commentaire