Category : boolean

I was solving this problem I found online and I am doing something wrong because when I run the code it does’nt display anything.Can someone tell me what is wrong with my code? The problem: You are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents ..

Read more

I am creating a program that compares all the values of an array and reads which values add up to the desired sum. If there aren’t any values that add up to the desired sum, it should output a statement saying No matching sum was found, this is the part I’m having issues with. using ..

Read more

According to the answers in this question, std::vector<bool> implements "special" logic (to allow each boolean value to be stored in a single bit, rather than taking up an entire byte), and because of that, it doesn’t quite fulfil the requirements of an STL container and its use is therefore discouraged. However, the "special" logic is ..

Read more

I have coded a function which receives a double matrix and looks backwards for a zero entry. If it finds one it changes the value of that entry to -2.0 and returns true. Otherwise it returns false. Here’s the code: #include <iostream> #include <vector> bool remove1zero(std::vector<std::vector<double>> & matrix) { size_t dim = matrix.size(); for (size_t ..

Read more