Jestem początkującym, głowię się już nad tym za długo, ale nie chcę odpuścić. Muszę napisać taki program:
Task
Given an integer, N, perform the following conditional actions:
- If N is odd, print Weird
- If N is even and in the inclusive range of 2 to 5, print Not Weird
- If N is even and in the inclusive range of 6 to 20, print Weird
- If N is even and greater than 20, print Not Weird
Prosiłbym o wskazanie gdzie popełniłem błędy, albo skorygowanie kodu by działał poprawnie.
Z góry dziękuję.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
if (N%2!=0 || (N>=2 && N<=5) )
{
cout<<"Weird";
}
if (N%2==0 && 6<=N<=20 )
{
cout<<"Not Weird";
}
if (N%2==0 && N<20)
{
cout<<"Not Weird";
}
return 0;
}