Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; string ltrim(const string &); string rtrim(const string &); /* * Complete the 'divisors' function below. * * The function is expected

image text in transcribed

#include

using namespace std;

string ltrim(const string &);

string rtrim(const string &);

/*

* Complete the 'divisors' function below.

*

* The function is expected to return an INTEGER.

* The function accepts INTEGER n as parameter.

*/

int divisors(int n) {

}

int main()

{

ofstream fout(getenv("OUTPUT_PATH"));

string t_temp;

getline(cin, t_temp);

int t = stoi(ltrim(rtrim(t_temp)));

for (int t_itr = 0; t_itr

string n_temp;

getline(cin, n_temp);

int n = stoi(ltrim(rtrim(n_temp)));

int result = divisors(n);

fout

}

fout.close();

return 0;

}

string ltrim(const string &str) {

string s(str);

s.erase(

s.begin(),

find_if(s.begin(), s.end(), not1(ptr_fun(isspace)))

);

return s;

}

string rtrim(const string &str) {

string s(str);

s.erase(

find_if(s.rbegin(), s.rend(), not1(ptr_fun(isspace))).base(),

s.end()

);

return s;

}

Watson gives an integer N to Sherlock and asks him: What is the number of divisors of N that are divisible by 2?. Input Format First line contains T, the number of testcases. This is followed by T lines each containing an integer N. Output Format For each testcase, print the required answer in one line. Constraints 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

=+ How well do you think you could do your job?

Answered: 1 week ago