Beginners - July 2019 (Page 6)

A logic explanation about averages
 
Hello, we are writing a homework code about finding the average of odd numbers in an array. Someone helped us a little with the code, but I can't figure out log...
[6 replies] Last: @ jonnin Yes, agreed that new code is typically fine with doubles. @... (by Duthomhas)
strings to numbers
 
I am trying to input two numbers as c strings, it should be 4 digits long and should contain no letters. This code gives me C3687 and C2446 errors. I am tryi...
[16 replies] Last: or the 2 cent answer, std is too big, so its better to do smaller usi... (by jonnin)
by dutch
efficient coding
 
You should get 90 points just for reading that pointless pile of garbage. codechef sucks and teaches nothing.
[14 replies] Last: you are messing up the update part. index= 0 1 2 3 4 value= 3 9 10 11... (by ne555)
Why are these codes doing this?
 
Here are two different codes with the same information just about. But each code is different. Each time I run one the output is vertical, when I run the other ...
[3 replies] Last: ... (by highwayman)
One-run functions?
 
I’m not entirely sure, but isn’t there a way to make a function so it only really runs once and then the rest if the times it just returns the computed valu...
[9 replies] Last: Sorry that’s supposed to be VARS not CARS so sorry XD thanks for the... (by highwayman)
can vectors be used without invoking copy constructor?
 
Hi I have a vector V which contains objects of type O. Generally, I want to prevent O from being copied so I've made the copy/assignment operators private. ...
[3 replies] Last: > Is that because std::ofstream has deleted copy constructor/assignmen... (by JLBorges)
To divide the elements into K segments such that the sum of minimum element of each segment is maximum
 
Given an array of N elements divide the elements into K segments such that the sum of minimum element of each segment is maximum Sample Input : N=4 K=2 1 2 5...
[2 replies] Last: Note that the sample has a second solution: [1,2]+[5,3] The task is a... (by keskiverto)
vector rend call
 
I was expecting following program output 1.But for some reason I am getting output of "201360154". int main () { std::vector<int> bar = {1,2,3,4,5}; ...
[3 replies] Last: About std::vector::rend.... Returns a reverse iterator pointing to t... (by George P)
Compile time string build function
 
I want to build a string/char in the compile time. constexpr char INPUT = "abc"; // input char /// Not Working Function /// But that is what I want c...
[7 replies] Last: Here's a very sloppy but still much nicer version in the value domain:... (by mbozzi)
Help stuck in this problem
 
Help me in removing wrong answer in this program? This is the problem: There are N bottles. ith bottle has A radius. Once a bottle is enclosed inside another...
[1 reply] : Hello counter strike, PLEASE ALWAYS USE CODE TAGS (the <> formattin... (by Handy Andy)
Operations Program, Need guidance
 
I have a program I need to code that: Handles 25 interger numbers. Declares Array A and B. Fill Array A from input file "numbers2.in". Fill Array B with 25 ran...
[9 replies] Last: @CodeNovice01: Read http://www.cplusplus.com/doc/tutorial/functions/ a... (by keskiverto)
With functions and arrays
 
If I have a program and I need 'Array A' to read in values from an infile, how would I make that into a function? And also 'ArrayB' needs to be setup with 25...
[8 replies] Last: Jonin, I appreciate the advice, as of right now my professor wants us ... (by CodeNovice01)
Shortening this comparison code the right way
 
This code is inside a while loop and version 1 works, but I guess the code is too big and readability is bad. The array that needs to be ckecked is always going...
[4 replies] Last: is this really do { code } while (something and all the combo test... (by jonnin)
by dutch
dsj vjskd
 
I solved only subtask #2 What was your algorithm? EDIT: Original poster has disappeared.
[17 replies] Last: don't check every combination, check only the ones that occur between ... (by ne555)
Dynamic cast vs static cast
 
hi guys, again I'm watching one of Jamie kings videos ( https://www.youtube.com/watch?v=0AuPWXuBmyo ), in one aspect it's helpful in another it's not, the as...
[8 replies] Last: very true :) (by adam2016)
Function issue
 
Hello everyone, I'm currently learning c++, so still don't understand everything so please forgive me for my lack of knowledge. Here is my issue, i'm trying...
[4 replies] Last: No, ::variable would only be need to explicitly reference a variable i... (by Ganado)
Restructuring a GSL matrix
 
I have a set of K*K square matrices and I would like to create a new (K+1)*(K+1) square matrices where each K size block matrix copies in this new one then ther...
[3 replies] Last: I'm not familiar with gsl , but taking a guess, try moving gsl_matri... (by dutch)
by medosz
Factorial with while statement
 
This program reads a nonnegative integer then it should compute and print its factorial with while statement. For example 5! 5*4*3*2*1=120 I get 0 as resoult....
[1 reply] : Your loop goes one-too-far, ultimately multiplying the result by 0. ... (by dutch)
Help me to understand these sections of code
 
So, i am going through the book 'Beginning C++ Through Game Programming'. I have reached the Hangman game and am trying to understand a few sections of code. ...
[5 replies] Last: This mean until you get no match. (by Zaap)
Vector crashing
 
Why is my vector program kept on crashing There's the question: 5. Use C++ Standard Template Library <vector> to do the followings: (a) Declare a vector name...
[13 replies] Last: > so actually we couldn't use assign() function to assign the value 5 ... (by JLBorges)
July 2019 Pages: 1... 45678... 11
  Archived months: [jun2019] [aug2019]

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