Intro to Conditional Statements Solution in CPP
This Page Contains the Solution in Cpp Programming Language for the Day 3 : Intro to Conditional Statements, Code Challange of the HackerRank 30 Days of Code.
#include <bits/stdc++.h>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
int main()
{
int N;
cin >> N;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
// Complete the solve function below.
if(N%2==0)
{
if(N>=2 && N<=5)
{
cout<<"Not Weird";
}
else if(N>=6 && N<=20)
{
cout<<"Weird";
}
else
{
cout<<"Not Weird";
}
}
else
cout<<"Weird";
return 0;
}
string ltrim(const string &str) {
string s(str);
s.erase(
s.begin(),
find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace)))
);
return s;
}
string rtrim(const string &str) {
string s(str);
s.erase(
find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(),
s.end()
);
return s;
}
PreviousIntro to Conditional Statements Solution in C ProgrammingNextIntro to Conditional Statements Solution in C#
Last updated
Was this helpful?