Spent some time to implement graph as adjacency list. Looking for suggestions on how can improve this implementation
#include<vector>
#include<iostream>
class Graph{
public:
//n is the number of vertices in graph
Graph(int n)
{
N=n;
E=0;
//for(i...
As an ongoing little side project of mine, I've been working on recording audio with the C language. You can see a progression of my code by looking at my past two versions (V1.0, V2.0).
I've decided that my past versions of this code were too limited. They required a certain time frame for wh...
Ken, Despite reading the site instructions, I could not determine how to edit appropriately. It was an honest mistake. I am a rare poster. I did not notice the "more comments" link to see that David "reverted" my code. I thought it wasn't saving. I appreciate the help but neither yours or Davids comment were instructive. I can't add, "ok, like this?". I must just create a new question? Is it that the first question was specific to pointers and I was wanting too much detail about the code and where it was created and freed? What is the "code review site"? Thanks! — F. Decker1 min ago
@david I'm around but still no time for code review, and I guess you mean someone else anyway, because here I had only a small suggestion... But basically you can call get with timeout and if you get the TimeoutException, you call cancel. — lbalazscs36 secs ago
One time, I unplugged my Mac from the wall. Then I plugged it back in and pushed the power button. After I put my password in, my desktop looked identical to what it was before I unplugged it (apps reopened, Xcode had everything I had typed, etc)
this is my solution for exercise 1-19 of K&R (Write a function reverse(s) that reverses the character string s. Use it to write a program that reverses its input a line at a time.)
It works, but i'm trying to write good programs, i think the fact that i can't use the length of the vector when al...
@HoboSapiens Being on-topic at Code Review and off-topic at Stack Overflow are not the same thing. Being on-topic at Code Review is not a close reason. If you feel this would be better on Code Review, then flag it for migration. If you feel this is off-topic for Stack Overflow for a reason defined in the help center, vote to close for that reason. — nhgrif10 secs ago
float avg(float *data, size_t length)
{
float sum = 0;
for (size_t i = 0; i < length; i++)
{
sum += fabs(*(data + i));
}
return (float) sum / length;
}
So, data is an array, right? Why don't we treat it like one and access it using subscripts?
float avg(float *da...
@nhgrif There is no mechanism to flag for migration to Code Review. Even if there were, the migration routes that are available are all listed under the off-topic close reason — Hobo Sapiens38 secs ago
There IS a method for flagging for migration to Code Review: i.imgur.com/0KTrS7Z.png Moreover, although those are listed under the off-topic close reason, the difference is that when a question receives enough of those votes, IT IS ACTUALLY MIGRATED, whereas when we close it using your method, it's just closed and it's up to the user to repost it. But finally... IS this question off-topic for Stack Overflow based on one of the reasons defined in the Help Center? If so, why can't you choose that option and then offer a comment recommending the user check out Code Review? — nhgrif1 min ago
I can't agree with goto being "absolutely unwarranted" without a recommended cleaner alternative. I can think of a better approach, but just eliminating goto either ends up in quite a bit of duplication or deep nesting. — nhgrif22 secs ago
If it walks like an array and talks like an array, use it like an array.
float avg(float *data, size_t length)
{
float sum = 0;
for (size_t i = 0; i < length; i++)
{
sum += fabs(*(data + i));
}
return (float) sum / length;
}
So, data is an array, right? Why don't...
I ran into some problems when trying to use long to store the number so I decided to use BigIntegers (which i'm not really familiar with). But here's my code, and whenever I try to run it, the code compiles but never opens.
import java.math.BigInteger;
import java.util.*;
public class problem3
{...
@Mehrad - additionally, that circuit, is really converting the output from a volt-range to a 4-20mA proportional driver which I thought I could re-sense at the far end.
In other words, it is not something that you should use, if using an ADC at the source.
I am looking for suggestions on how to improve my mergesort.
My teacher explained the recursive mergesort and left the bottomUp one as as an assignment. I have implemented it but find it too messy. I thought the implementation would be more simple.
The question I am asking is how to make it more ...
> Pa_Terminate() MUST be called before exiting a program which uses PortAudio. Failure to do so may result in serious resource leaks, such as audio devices not being available until the next reboot.
exactly, I am writing up an answer... it starts with:
> Goto conditions are often maligned as being bad practice... and, for a reason. In almost every situation where a goto is used, it's because you are doing too much in a method.
I'm very new to Go (this is my first real program), and I was hoping to see if there was anything I was missing about the language or any ways to make it more idiomatic.
calculator.go
package calculator
import (
"../stack"
"unicode"
"strconv"
)
func Calculate(input string) int {
...
My code is complete. It runs properly and produces the correct output. I did calculations by hand to check and then ran the program and it gives me the same result. I just want a second opinion. Are there ways for my code to be more efficient? Are there small details that I need to change? My pro...
Is the following MS VS solution structure and classes OK w.r.t. easy unit tests with dependency injection? Would your unit tests look similar?
If you call the calculations below over a WPF module, would you skip a test over the WPF since complicated, or would you still conisder testing it over ...
CodeChef - QPOINT
class QPOINT
{
class Point
{
public double X;
public double Y;
public Point()
{
X = 0;
Y = 0;
}
public Point(double x, double y)
{
X = x;
Y = y;
}
}
...
@rolfl @Mat'sMug I was indeed asleep. @Duga is just posting information here about when some users creates new repositories (with a bit of delay). That's all.
What does "width incorrect" mean? What does "we need control sequence"? What is your actual problem? This looks like you have found two methods, and one is broken and the other works, and you are asking for a code review (which is off-topic for Stackoverflow). — Quentin54 secs ago
//Im trying to create an object that implements a Tic-Tac-Toe game. I can represent whatever state I want in the object, but the object must use the methods I've provided below.
// Input: player is a String that represents either an X or an O
// Output: return true if player won with...
Does this code even work? main() is missing a return type. If it doesn't work, you should ask about the specific problems that you get. If it doesn't work, it does not belong on Code Review. — Simon André Forsberg56 secs ago
@SouravGhosh Being on-topic at Code Review and off-topic at Stack Overflow are not the same thing. Being on-topic at Code Review is not a close reason. If you feel this would be better on Code Review, then flag it for migration using a custom flag. If you feel this is off-topic for Stack Overflow for a reason defined in the help center, vote to close for that reason. — Simon André Forsberg1 min ago
@SouravGhosh Simon didn't say the question was on-topic. He said the reason you manually typed in (being on topic on Code Review) is not a valid reason to close a question on Stack Overflow, and you should refrain from using this reason in the future. Sure, it may be off-topic, but if it is, you should close it for the reason it is off-topic HERE, not for the reason that it might be on-topic else where (because that doesn't make it off-topic here). — nhgrif19 secs ago
@nhgrif I see the point. So what shall I choose? codereview is not listed under the available sites for migration under off-topic vote. and BTW, just for my information, how you justify the presence of other 5 websites in the migration list? — Sourav Ghosh1 min ago
The other 5 websites are fully out of beta, and Code Review still regularly gets bad migration suggestions from Stack Overflow users. You can use the flag tool to flag for migration. Don't close it unless you can find a Stack Overflow-only reason to close it. Is this "Too Broad"? Is this "Unclear What You're Asking?" — nhgrif2 mins ago
@SouravGhosh I would choose "Unclear what you are asking" or "too broad". To flag for migration you click flag -> other -> and describe your migration request, and it will be up to the SO moderators whether it will become one or not. I am not convinced that the code in this question is really working though, as mentioned in some comments above, so I would not recommend this to be posted on Code Review. — Simon André Forsberg2 mins ago
Does anyone in here have experience wih java.sql.date? This code:
Calendar cal = Calendar.getInstance();
cal.set(1967, 06, 22);
long date = cal.getTimeInMillis();
r.setDateOfBirth(new Date(date));
System.out.println(r.getDateOfBirth());
Please do not double-post and perhaps try to avoid too much horizontal scrolling? Line length! I'll have a look at your question. — KIKO Software1 min ago
@Yann When it asks about understanding code, it tends to be about code that someone else wrote:
> I'm a newbie at programming working my way through stephen kochan's Programming in C. Chapter 7 of the book has an exercise that requires the reader to guess the out put of the code which is as follows:
@eckes Being on-topic at Code Review and off-topic at Stack Overflow are not the same thing. Being on-topic at Code Review is not a close reason. If you feel this would be better on Code Review, then flag it for migration using a custom flag. If you feel this is off-topic for Stack Overflow for a reason defined in the help center, vote to close for that reason. — Simon André Forsberg1 min ago
Summary
VB6 doesn't have a great selection of data structures to work with, so again I find myself creating my own. I have a need to dynamically generate a directory structure on the file system. The natural way to represent this is with a Tree, so I created my own.
There are three classes invo...
This guy has embedded HTML inside of his JS and it compiles and works
Nvm - it's JSX
apparently it is JSX and not JS?
surprised me, it looks completely identical otherwise. OP put it under the javascript tag too, I almost voted to close for broken until I saw his JSfiddle
well.. he is now the first person to ask a jsx question, congratulations to him
This is not a code review thing, it is a engineering issue. That comparison should not be done at php it can all be accomplished with a Query. With some joins he could get the orphans rows. — Daniel Aranda1 min ago
yeah it's not working so well for me. I am trying to make something look nicer and I really don't have to, but I want to....lol
simple Session Timeout Timer in Javascript. and I am trying to turn it into a user control, and I am trying to use css classes instead of tag ID in the javascript. it would make it easier to have more than one on a page
@nhgrif stupid VB, just has to do things the wrong way....
I might not do the whole user control thing, but I do want to get into using the Class instead of the ID, because the ID makes me have to write more code for the second timer on the page, which I think is Ridiculous