Besides the fact that I use using namespace std; how can I make this code more efficient?
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
int number1=100001;
int number2 = 100001;
int tries=0;
cout << "Please enter a number between 1 and 100000: ";
cin >>...
@CaptainObvious Why do people delete their question so early?
Was about to comment this:
> Your approach of letting the computer "guess" the inputted number is not effective, it can take forever for the computer to do this. The fact that you are printing to sysout inside your loop is a big slow-down. But you do have a potential infinite loop here. If you would help the computer out by telling the computer if the value is higher or lower then it would be more effective, and more interesting (sort of like an inverted number-guessing-game)
how do you mod people feel about more than one comment flag on a thread, if one is on the question's comment and another is on an answer's comment and there is a different reason for both?
I am in the process of writing a program that will take IP addresses and subnet masks and validate the information. If the information is not valid, they will be displayed as invalid or be assigned a default value. I am really running into a problem trying to validate whether it is an assignable ...
I'm currently faced with a dilemma in our SQL Server environments. We need to migrate our existing logins, users and roles to a new login, user and role with the same permissions as the old. I've been tasked with writing a stored procedure that will accept 3 parameters:
Database Name
Old Role
N...
Our current situation:
We are getting 34 questions per day
We are getting more and more unanswered questions
We are still on a mission
I feel that we multiple times per day get questions that are a form of "I wrote xyz, how can I improve it?" often with very little explanation about the code ...
Our current situation:
We are getting 34 questions per day
We are getting more and more unanswered questions
We are still on a mission
I feel that we multiple times per day get questions that are a form of "I wrote xyz, how can I improve it?" often with very little explanation about the code ...
@JerryGoyal - I do not have the time to really think about it too deeply. All I would way if this was for code review I would not look at it twice. It is unreadable. Very difficult to understand. Not maintainable. — Ed Heal19 secs ago
@DaveNewton Most of the "better fit on Code Review" questions tend to be closed as "too broad" or "primarily opinion-based" on Stack Overflow, which is more preferred than "off-topic because it belongs on Code Review". The "belongs on another site" close reason, migrates the question, not closes it (and there are several reasons why CR is not in that list). If you want to discuss more about this, you are very welcome to chat with CR regulars in The 2nd Monitor — Simon André Forsberg41 secs ago
@YePhIcK - People trying to allow such code are damaging software quality. I would have thought that the answer is not to try to figure it out but to mention in the interview situation that code reviews are important and making code readable. Perhaps that is where the interviewer was trying to lead the interviewee — Ed Heal1 min ago
I need to get folder names with the path for which I need to search the directory in a server with about 6000 folders. I have the following snippet of code to run through the folder and get the folder names with path. It works fine in a local directory but when I run the same code on a server dir...
This problem is to be solved using level traversal logic only.
Just when I thought I had covered all the cases and nailed it, this program crashes on running and I can't figure out why. Kindly help.
Basically, I'm required to delete all the nodes that don't have a sibling, i.e. the single child...
> Well I currently use jdom in a project with robovm and since that is constrained to what the jfxports JDK has implemented, a dependency on the streaming api would break that. However, I am happy with 2.0 and it is not clear to me how long it will take until jfxports have support for that API, so maybe not a big thing to base decisions on. Just thought, I'd mention it, since robovm gets a bit of buzz these days.
@SimonAndréForsberg This comment (from Ed Heal) is even more stupid than that. Closing things as duplicates is actually sort of good. Sometimes, things get posted then closed as duplicates because whatever search terms the duplicator used didn't bring up the other question/answer. Linking them as duplicates increases the number of searches you can perform and get to the same answer.
It may be the case in this specific situation that the duplicator didn't even google first, but nonetheless...
I don't downvote duplicates unless I try searching for some of the search terms I'd guess at base on their question and can't find the question it's linked to as a duplicate.
Maybe the duplicate linking needs to be separated from the closing function?
And in fact, does it make complete sense to close Question A as a duplicate of Question B always? Sometimes people argue that the two questions aren't even related at all, but they get closed as duplicates because an answer to B could be verbatim posted to A and answers it exactly. Maybe we should vote "This question has already been answered", and pick an answer, which would still close the question and link the questions, but make the selected answer show up on the page for question A?
its a number guessing game, and there is one problem. Its a guessing game for the computer. I can not figure how to add the option where "is the number High, low, or correct?" ANY Suggestions? also I remove the def main(): because it would not read the rest after "won the battle"
thanks!
from ra...
If you have no questions with net negative votes, but all of your questions get closed as duplicates (and only for the duplicate reason), will you eventually be question banned?
And I say this primarily in light of the stupid debate going on at MSO about some "Swift" questions being closed as duplicates of "Objective-C" questions.
I am a beginner at python, taking an introductory course. My professor just assigned a program to us. However, when he assigns he has a problem with not really going too much into what needs to be done and only gives you the most tiny bit of information to go on. If you try to approach him he act...
So... as a developer, I am right in arguing that my (or any developer's) salary should not be based on the success of the product, but rather how well I deliver code according to the specifications I am provided, right? I mean... right? Unless I'm self-employed...
> a fixed regular payment, typically paid on a monthly or biweekly basis but often expressed as an annual sum, made by an employer to an employee, especially a professional or white-collar worker.
So with that in mind, it wouldn't make sense for anyone to accept anything less than what they could get on the open market unless there are other factors in play (like the schedule if more flexible and I need that, or the atmosphere is better, etc)
But you definitely shouldn't be accepting less than what you can make on the open market on the pipe-dream promise that "when the product becomes successful, everyone will make more" (a verbal "promise" and nothing more than that)
I have to make a big decision within the next couple of weeks... and I'm trying to make sure I'm making the right one.
I think part of the issue is that there aren't enough reviewers in general and certainly, some languages suffer from this more than others. So, rather than "Do we need to make it harder to ask?", we need to ask ourselves "What can we do to attract more reviewers?". Personally, I don't answer as much as I used to because I simply don't have the time to anymore. — RubberDuck40 secs ago
@nhgrif It's not your product, it's the company's product. So, yes. You're correct. Unless you have an actual percentage of ownership of the company, your pay should not be dependent on the success of the product.
The company was started by a guy who owns two other companies. He needed ERP software for his two companies, and didn't like anything available on the market, so he started his own software. Eventually, they spun that off into its own company.
ERP is not cheap. And his two other companies get unlimited licenses to the software without paying... so there's a gray area in terms of actual revenue, but I don't think its relevant.
I haven't been here since the beginning, not even close, but I'm starting to think that for an entire ERP system, there were never enough people here that you'd actually need to support paying customers of an ERP system.
I know what the (approx.) revenue is and it doesn't count anything from the other two companies.
But I'm not even sure any of that is relevant.
Given that all employees are either salaried or hourly (except sales people who are commission based), our pay shouldn't even take revenue into consideration.
My argument is that we barely have enough to support our current customers, and we can't really take anyone new on (because I'm not going to work 100 hour weeks), while the otherside of the table is arguing that there's not enough revenue to justify paying the amount I'm talking about for new hires (nevermind my own salary) (I have taken on all the responsibilities of my old boss, in addition to ones I already have, so I now have more responsibilities than he ever had, but we've not negotiated
my salary since this change.
And it's possible that the decision makers might be out of touch with how much developers cost in today's market.
So, unless you really really really like the place, you should just be getting paid at least as much as you expect to be paid conform the current market
Between in-house libraries, database structure, and just learning the big complicated software from a user-perspective, there's a massive learning curve.
The larger the learning curve, the more expensive turnover is...
And among other things, the farther your salary is below market value, the more likely turnover is...
I just pretty much reverse studied a subject... or however you want to call it, I think Artificial Intelligence by our study books is very very complicated, gave up most hope. We were allowed to bring a piece of A4 paper with notes though, so I looked through an older exam + solutions and I actually do manage to understand most of it, there's still hope!
Presenting you an implementation of the "shear and transpose" method of rotating a bitmap image. It works.. but it works slow, which is fully understandable. It is understandable due to the evident lack of optimization. Notwithstanding it doesn't interact with the VGA or any library for that matt...
So, it's really not even about my salary. Because if my coworkers aren't also paid competitive wages, then they will be regularly getting raises just by working any where else, and that means we have to go through the hiring process again, and I have to help people learn all of this stuff all over again.
So then... if a developer weren't purely salaried, but instead had some sort of incentivized/equity/options based pay figured in, then at that point you have to weigh risk vs reward, right? It would only make sense to take that choice if you were confident that these incentives/options/etc would pay out.
DoAlertmight have too many arguments. There's no possible way to write clean code when you have a method that takes 10 arguments, made worse by the fact that four of them are closures. — nhgrif1 min ago
Because it's a huge complicated system with lots of interconnected parts?
When we hire new developers, we try to put them on stuff that has as little interconnectivity as possible, but that doesn't always work.
Even if we always managed to do that, it's not always going to be something that we actually need to be done.
Part of the problem is the short-sightedness of previous developers. Things aren't very well documented. Things aren't as clear as they could be.
I've tried as best as I can to get some things put into a frame that can be more quickly picked up by new people, but given that there's roughly 12 hours worth of "this has to be fixed immediately" problems in any given day, I don't always get a lot of time to work on this.
And efffectively, I'm the only developer who is even allowed to touch our COGS stuff.
I could see something like if you fork a repo because you are interested in it, but parts of it you are not sure what is going on and would like some help
I'm currently enrolled in an introductory C#/.Net 4.5 course and one of the things I want to focus on is the quality of my code.
This is the first assignment our instructor had us do, the ever-popular number guessing game. The requirements our instructor set out for us were:
On startup, the p...
I've retracted my close vote, buy I strongly recommend you edit your post to make it clearer that it just appears to hang and actually works, since questions involving non-working code tend to quickly get closed on this site. — Mat's Mug2 hours ago
hmm...
I have modified the code as well to handle error and enable cancel key but status bar doesn't update after some time and pressing escape also doesn't get me out of the loop. — Anurag Singh24 mins ago
@Speedwheel I think Ian was recommending you post this to Code Review. It might be on-topic there. I recommend you read the help center. This question might receive better answers there, assuming everything here is working as intended. — nhgrif31 secs ago
My action classes would often have an action field variable that was assigned a value inside the execute() method:
public class MyAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private String action;
@Override
public String execute() throws Exce...
I think I put too much code in my controller that was supposed to go in the model.
This is a part of my controller, I'm not gonna paste everything since there is a lot of code.
public function ajaxUsers() {
if($_GET["action"] == "listUsers") {
if(!isset($_POST["search"])) {
...
I need to find the sum of some numbers in a tuple, in a list, in a dictionary in a pickle file, then divide it by three, display the key and result, and repeat for every key and value in the dictionary. I keep trying everything and the only thing I think will make the code work is:
for key,value...
I've edited your question to remove a lot of unnecessary details and focus your question on a single topic. I know it may sound harsh, but readers don't really care how new you are to a topic, and mentioning things that you aren't going to ask about doesn't help anyone. Questions should describe your situation and the problem you're having, and nothing more. For future reference, when you have working code and just want to improve it, consider Code Review as another resource.Good luck with your coding! — skrrgwasme1 min ago
I built and uploaded my app to itunes connect using the release version of xcode 6.3 last night but it was rejected as "invalid binary". The email from app review said I was using an invalid or beta version of Swift.
I would really appreciate any help or ideas about how to work around this probl...
You're asking the guy who keeps ranting that we don't downvote enough @SimonAndréForsberg. I don't think I can objectively answer that. — RubberDuck2 mins ago
This is what I have so far. I've implemented the ability to take in weights from the user, a bonusPoints module and a classInfo module as well as removed the using namespace std and completely rewrote the assignmentScore module.
I'm using a single function to grab the weighted value in each of t...
I think it should probably be a CW answer.
I meant to flag it after I posted that comment, but forgot.
Note, this is not an answer, but a new question requesting help to resolve code that does not yet work. It is not a candidate to be a new Code Review question because it is not working. Since this is a question, it is also not a candidate to be a "self answer". Please see What you may and may not do after receiving answers — rolfl ♦6 secs ago
Yeah. I chased around some really difficult code for a long time before I realized that MS neglected to doc their out params that completely solved the problem in a sec.
Someone asked me the other day when they should use the parameter keyword out instead of ref. While I (I think) understand the difference between the ref and out keywords (that has been asked before) and the best explanation seems to be that ref == in and out, what are some (hypothetical or code)...
Apparently, someone wrote an essay to be tested by a one of these programs, and stated that the rising costs of college were because of TA's who got paid exorbitant amounts, got access to private jets, vacations, and other ridonculous things.
if (!TryExtractUsernamePassword(Request.Headers.Authorization, out adminEmail, out password))
{
return Unauthorized();
}
User user;
if (!_userRepository.TryLogin(adminEmail, password, out user))
{
return Unauthorized();
}