Beginners - March 2022 (Page 4)

by zy96
Travelling salesman problem solver.
 
Hi all, I am actually working on one C++ program to solve a travelling salesman problem. Here's the brief introduction on what the program intends to achieve. ...
[11 replies] Last: It has 2 member variables and one constructor that takes 2 strings. H... (by seeplus)
Program doesn't execute correctly
 
Hi everyone, as soon as I execute the program that I got below, it first calculates for a couple of minutes and then starts to output infinite 'L's no matter w...
[6 replies] Last: I'm using MinGW on Windows on VS code.. Thx for all the help i got it ... (by AustrianProgrammer)
Pass by reference function
 
I wrote this program to turn it into a pass by reference function, but I don't know where to start or what to do #include<iostream> #include<cmath> us...
[3 replies] Last: [Duplicate - See http://www.cplusplus.com/forum/beginner/282706/ ] (by seeplus)
Passing by reference without global
 
I am not sure what I am doing here, I was given a formula to use in the passing by reference and my lecture was not helpful at all. I am also supposed to put th...
[12 replies] Last: Assuming the calculations are correct: #include <iostream> #include... (by seeplus)
Char & int input
 
Hey guys can i ask how to make my code accept both int and char input?
[2 replies] Last: A variable has a type and it's value can only be valid for the specifi... (by seeplus)
Mergesort using iterators gives nonesense output
 
Hello together! I'm supposed to implement a mergesort algorithm using iterators. I've implemented the algorithm as shown in books and on google, but somehow it...
[2 replies] Last: Thanks a lot for helping out! (by Mae4ashy)
Inventory program
 
Hello, new to C++ and this forum too. I am currently going through object oriented C++ classes at my local college. I want to write a program that stores inv...
[3 replies] Last: that using a vector and then deleting from a vector would be ideal, h... (by seeplus)
by ThatYe
Initialize a variable with an expression
 
Hi, Is it impossible to initialize a variable with an expression such as double perimeter { width + length }; double length { 2 * (width + length) }; for...
[8 replies] Last: My code could have been a lot better by seeing your codes and reading ... (by ThatYe)
#include <S.h>
 
You mean this piece of software? https://github.com/Kraus-Lab/groHMM
[6 replies] Last: Poor netiquette, but probably wasn't a spambot. But that's what happen... (by Ganado)
Issues with 'if-else loop..
 
I am working on a project(again) and am running into an issue with this code. I am trying to choose a "plan" and my cin works to type in a plan..but then repeat...
[5 replies] Last: As the same prompt/input is required for each plan, why not as a start... (by seeplus)
Stringstream not working
 
Hi, I don't understand why the last row in the terminal is not 5. When I comment out "ss >> name" or use a new stringstream just for weight this works. Why? (Te...
[3 replies] Last: Why not simply: std::string input, name; std::getline(is, input,... (by seeplus)
by danyef
stderr: terminate called after throwing an instance of 'std::length_error' what(): vector::_M_range_insert
 
0 I need to implement a simple version of schedule for monthly tasks. For example payment of electricity bills, subscription fees for communications, etc. ...
[2 replies] Last: Use the debugger to trace through the code so see where the error occu... (by seeplus)
Issues with 'for' loop..
 
I have been working on this problem for at least an hour. "First, read in an input value for variable numIn. Then, read numIn integers from input and output ea...
[4 replies] Last: In the OP code above, if the >> numIn fails because a non-number is e... (by Ganado)
rouge \n
 
Hi, Can someone explain closer why a "\n" prints after the second "You wrote". Terminal: hi; a You wrote: hi and a bye; b You wrote: bye and b Code: ...
[3 replies] Last: Presumably OP means a "rogue" newline as opposed to a red one. :-) (by DizzyDon)
by ThatYe
Program that detects repeated words
 
I don't understand in details how this little program detects adjacent repeated words in a sequence of words. So my question is how the program proceed to do i...
[16 replies] Last: #include <iostream> #include <string> #include <cctype> int main() ... (by seeplus)
Taking byte stream (1s & 0s) and storing them in a uint8_t array
 
I am trying to take this byte stream of information (1's and 0's) and im trying to store this in a uint8_t array (each index would be a byte long, 8 bits). I am...
[3 replies] Last: #include <iostream> #include <bitset> #include <iomanip> int main() ... (by againtry)
Count how many times a solution is printed
 
For the life of me, I cannot figure out how to count each time I print the solution, and the total number of solutions. I know it is something I forgot from ear...
[1 reply] : Well you have a return statement. Which you ignore all over the place... (by salem c)
Does the compiler do anything during runtime?
 
I'm reading C++ Primer 5th Edition by Lippman. In the chapter leading up to the topic of smart pointers, this was said about static and automatic variables: S...
[7 replies] Last: It might be helpful to review the process of compiling C++ code into a... (by deleted account xyzzy)
by AAAbb7
Trouble declaring a user
 
I keep getting this syntax error for my code: __tester__.cpp: In function ‘int getCountWatchedMovies(std::__cxx11::string, User*, int, int)’: __tester__.cpp...
[5 replies] Last: My getter/setter rant: I'm not a fan of getters and setters when used ... (by AbstractionAnon)
by Pen72
Given integer sequences
 
Given three integer sequences A=(a1,a2...ana) ,B=(b1,b2...bnb) , C=(c1,c2...cnc) Find the numbers of tuple (i,j,k) such that ai>bj and bj<ck The fi...
[3 replies] Last: Yes, it worked. Turned out the data type should be uint64_t to hold th... (by Pen72)
March 2022 Pages: 1234567
  Archived months: [feb2022] [apr2022]

This is an archived page. To post a new message, go to the current page.