The problem: I have 2 arrays A[v] and M[w], with length v and w, respectively. Given two numbers p and q, I want to find how many combinations of the sum of two elements of these arrays satisfy the following condition: p >= A[v] + M[w] <= q An example: Let: A = [9, 14, ..
Category : arrays
After compiling my ReverseEx.txt is full of unknown characters. It might be because I don’t pass the values correctly or because the reversing function is not correct. Although the code is running. #include <iostream> #include <fstream> using namespace std; int main() { //Files ifstream Myfile; Myfile.open("Myfile.dat"); ofstream ReverseEx; ReverseEx.open("ReverseEx.txt"); string str; //Getting the text from ..
I compiled a COVID model (FORTRAN source) under a full installation if cygwin (GNU compilers) and all other subroutines "know" of the scalars and array values/settings after the initialization (reads in a namelist, allocates arrays, initializes arrays) and all are subsequently known by the other subroutines and it runs fine. When I use Visual Studio ..
I’m working on an audio visualizer and one of the functions records all the users key presses, while another function replays the recorded key presses (with an interval of time between each key "replay"). I declared a variable which increments in the update() function, however, as soon as the program iterates to the second key, ..
How to find Moore neighborhood in n-dimensional row-major array? I trying calculate indexes of neighbors, but it dosn’t work on borders Source: Windows Que..
I’m trying to have a struct take possession of a pointer to an array of pointers to objects on the heap. In order to not have to worry about deleting these objects I want to use smart pointers. However, I can’t seem to find a correct syntax to do so… This is what (I think) ..
I’m trying to implement my own math library, and I’m starting off with vectors. The idea is to give the class a pointer to an array of numbers, then copy the array and store it in the data address given by a private variable pointer. To begin with, I used alloca to try and free ..
I give online coding contests, where the speed of the program is everything. Over the time I have come across 3 ways to use the concept of array in C++. The questions of the contests usually require us to create a dynamic array of the given size. So its just a one time creation of ..
This program basically reverses a number like 4568 to 8654. It is not taking proper input. I know of other ways to do this but could you suggest me how to make this program work. #include<iostream> #include<math.h> using namespace std; int main() { int num[25]; int a, b, c, d; cout<<"Enter the no. which you ..
I am trying to make a program that simulates a game of dominoes. For this I have to randomly shuffle the pile of dominoes but I cannot figure out how. I have searched this but everything I have tried has failed. Is there a way to do this? Here is what I was attempting, the ..
Recent Comments