General C++ Programming - December 2021

by frek
Get updated and ready for important C++ exercises
Hello all, I'm an experienced C++ programmer with the absence about a year from it. Now I should recall and update my understandings of C++ to its current stan...
Dec 29, 2021 at 8:14am
[1 reply] : I would recommend the exercises from B. Stroustrup's book. https://ww... (by thmm)
Math: how calculate the line dots?
the line have origin and destion points. how can i calculate the dots between the line origin and destination. i create these code: #include <iostream> #in...
Dec 28, 2021 at 8:46pm
[15 replies] Last: 3D Rotation: https://imgur.com/qOgUuPf 2D Rotation: https://imgur.com... (by Cambalinho)
fastest find and replace for a string (1,2,3)
This is how I'm doing it; is there a faster way? The program could do it millions of times, so I expect any time savings would improve it. std::regex dou...
Dec 26, 2021 at 2:42pm
[59 replies] Last: Here is a search and replace (SAR) by simple string indexing. I use a... (by oggin)
Eigen is not fast??
(Edit - OP has vanished: or been assisted to depart) Well, dividing by 0 is quite fast ... if not very enlightening. Matrix3d m2; m2 << 1, 2, 3, 4, 5, 6, 7...
Dec 24, 2021 at 11:12pm
[3 replies] Last: I guess the OP has vanished, but Eigen is likely to benefit substantia... (by mbozzi)
by Cplusc
Sparse Matrix transpose
hello everyone. I have a matrix in which most of the elements are zero. For efficiency purpose, I stored this matrix in csr format(Compressed row storage). Now ...
Dec 24, 2021 at 6:04pm
[16 replies] Last: ...and now the transpose is ridiculously easy. :O) (by Duthomhas)
How to avoid dynamic memory allocation, and templates for matricez using Eigen library in C++
Hello dear all Look i am using the library Eigen, for Matrix and vector calculations. when, i tried to generate a matrix using advance initialization i want t...
Dec 24, 2021 at 5:04pm
[8 replies] Last: Jonnin, i never got such an nice answer telling the truth, Thank you v... (by baezacaljo)
how to find the highest sum of a subsequence
How to write a program in C++ to find the highest sum of subsequence elements of a given sequence? At the input, the user gives the length of the sequence and t...
Dec 24, 2021 at 4:36pm
[5 replies] Last: #include <iostream> #include <vector> using namespace std; int bestS... (by lastchance)
by frek
Range based for loop
Doesn't mean for (const auto& x : v) { /* do something with the value of x */ } this for (auto x : v) { /* do something with the value of x */ } supposing v...
Dec 23, 2021 at 4:12pm
[4 replies] Last: ^^^ that is a whole new discussion, but the & means that changes (if y... (by jonnin)
object not dynamically allocating
when i try to allocate new memory of an object of structure type, it gives a "read access violation" error. ftn that does that Voter* create_voter_node(s...
Dec 22, 2021 at 5:43am
[8 replies] Last: I assume @seeplus is asking about line 7 of the first snippet of code ... (by mbozzi)
by Cplusc
Vector indexing
Hi everyone. Is there any way to give arbitrary indexing to a vector? For example I have a vector a={1,5,6,2,7,0}. Now the indeces are 0,1,2,3,4,5. I want the i...
Dec 21, 2021 at 11:19pm
[10 replies] Last: A trivial method: #include <vector> #include<string> #include<iost... (by oggin)
Check input time format
Hello! I had a task - The program requests time in the format hh: mm: ss and checks the correctness of the input. I have created the code, but entering the exam...
Dec 21, 2021 at 11:49am
[3 replies] Last: This works with VS: #include <iostream> #include <string> #include ... (by seeplus)
by Cplusc
MPI_Allreduce for object of a class
Let's say I have a class named Node. A user defined vector of objects of this class is std::vector<Node> Nodes. Each Part of this vector is built in different p...
Dec 20, 2021 at 12:29pm
[3 replies] Last: Thanks for your answers. It was helpful. (by Cplusc)
by arnesc
tableprinter - Table-like output
I have written a small library with the help of iomanip and ostream header which allows a programmer to print table-like data. I am using this table-like format...
Dec 19, 2021 at 3:14pm
[5 replies] Last: Thank you :) I refactored function object passing part and made value... (by arnesc)
Recursion Function
Hello, currently im working on a homework problem that deals with recursion, the problem goes as follows: Suppose you can buy chocolate bars from a vending mac...
Dec 17, 2021 at 8:11pm
[10 replies] Last: Thanks! I believe Line 21 should have read return money + get_bars_1... (by mbozzi)
Help C++
First, I wish you all a good day. I'm trying to solve some problems in c ++ (I think it's important to let me know that I'm still a beginner and I don't unde...
Dec 17, 2021 at 3:47pm
[2 replies] Last: @The apprentice, PLEASE USE CODE TAGS (the <> formatting button to ... (by JRManx)
Generate a template class for a Matrix using vectors or change to Eigen library, C++
Hello dear all i am new using this forum. i have a question look, i have a project on which we are using several classes, therefore also several "Matrices", ...
Dec 17, 2021 at 12:40pm
[17 replies] Last: Thanks jonnin, I got it. Also, I searched for some info, and now I hav... (by baezacaljo)
by Cplusc
MPI
Let say I have a vector of vector in my master processor. I want to assign each vector to its corresponding processor. for example the first processor will just...
Dec 17, 2021 at 12:11pm
[9 replies] Last: sorry, I didn't provide a good example of my question. (by Cplusc)
Pointer Arrays
This is the pseudocode for the project: Declare the following prototypes : int sumSales(int list , int size); int winnerIndex(int list , int size); ...
Dec 17, 2021 at 2:17am
[7 replies] Last: they may work. its hard to say. you throw away the returned values! ... (by jonnin)
by ryuuki
alternating values
hi can you help me. i want to have my value in 2nd column under x1, ek0 and ek2 will become the value of my ek0, ek1, and ek2 instead this is the part of the...
Dec 15, 2021 at 11:37pm
[6 replies] Last: Thank you very much! I am just a beginner to this and just modifying e... (by ryuuki)
How to get the type of a variable without the "typeinfo" header?
I don't want to link the C++ (not even C's libc) and I want to learn how (and if) I can get the type of a variable for a comparison. For example I want to do so...
Dec 15, 2021 at 3:13pm
[17 replies] Last: Honestly, I don't see why it shouldn't be allowed to post on differen... (by jonnin)
December 2021 Pages: 123
  Archived months: [nov2021] [jan2022]

This is an archived page. To post a new message, go to the current page.
Registered users can post in this forum.