[solved] – Question 76524

Write a function reverse, that takes in a vector<T> and reverses the vector, i.e. modifies the input vector.

#include <vector>

using namespace std;

template <typename T>

void reverse(vector<T> v) {

//code..

}

Expert Answer


[solved] – Question 76525

Write a function reverse, that takes in a vector<T> and returns a new vector<T> that has the contents reversed.

Try practicing with and without using iterators.

#include <vector>

using namespace std;

vector<T> reverse(vector<T> v) {
//code
}

Expert Answer


[solved] – Question 76526

Write a function num_dups that takes in a string and returns the number of duplicated characters in the string.

Hint: You can use a std::map to maintain a count of the characters.

#include <string>

using namespace std;

int num_dups(string str) {
//code

}

Expert Answer


[solved] – Question 76527

Write a function max_freq that takes in a string and returns maximum frequency of the characters in the string, i.e. the highest number of occurrences of a character.

Hint: You can use a std::map to maintain a count of the characters.

#include <string>

using namespace std;

int max_freq(string str) {
//code
}

Expert Answer


[solved] – Question 76528

Write a function remove_odd that takes in a set of integers and removes all the odd elements.

Hint: you will need to use an iterator to iterate through the elements in a set.

Hint: In C++11, an auto keyword can be use to automatically infer the type. e.g. autoiter = s.begin()

#include <set>

using namespace std;

void remove_odd(set<int> s) {
//code
}

Expert Answer


[solved] – Question 76530

Write a function remove_odd that takes in a set of integers and removes all the odd elements.

Hint: you will need to use an iterator to iterate through the elements in a set.

Hint: In C++11, an auto keyword can be use to automatically infer the type. e.g. autoiter = s.begin()

#include <set>

using namespace std;

void remove_odd(set<int> s) {
//code
}

Expert Answer


[solved] – Question 76545

The purpose of this project is to acquire better understandings of the runtime stack mechanism by emulating it inside the source program. This project does not depend on Project 2 (but Project 4 will build on Project 2 and this one). We begin by describing the idea of the project with help of the factorial function.

Expert Answer


[solved] – Question 76553

Which language is best for software development? C++ or C#

Expert Answer


[solved] – Question 76554

Which language is best for game development?

Expert Answer


[solved] – Question 76577

Write a function remove_odd that takes in a set of integers and removes all the odd elements.

Hint: you will need to use an iterator to iterate through the elements in a set.

Hint: In C++11, an auto keyword can be use to automatically infer the type. e.g. autoiter = s.begin()

#include <set>

using namespace std;

void remove_odd(set<int> s) {
//code
}

Expert Answer