TRENDING NEWS

POPULAR NEWS

Need Help In A Java Program Arrays Just Rewrite It And Tell Me My Mistake.

Why are computer games written in C++ cooler than those in Java? What's the biggest game made with Java?

I was working at Gameloft for 2 years writing C++ games. The short answer is, because real game developers code in C++. Which means that the best engineers write C++. We also made some games with Java for old phones compatibility, but it was like a joke.Out whole engine was C++, the rendering, the web services, everything and the code was really good. Let place speed aside, because everyone talks about this, we actually prefer C++, because it makes our codebase better.I really do think that all serious software is C++ today. And with the new features, combined with boost and other libraries it is a beast.I think that Java is a joke for game development and one plus if you write your game in C++ is that it will run on any platform. iOS, Android, Windows, Linux, Mac all the modern OS support C++. Please try to run Java game on iOS. Although you should be a good developer to make it cross-platform with one codebase.Unity is good, because it's easy. For hackathons, indie games and etc. Even for AAA games, but please try to work with 100 more people on Unity project. Version control for Unity sucks a lot.Companies like Ubisoft and Gameloft has entire system for scene generation with the idea of multiple people working on one scene. This is important. Super important.You need entity and component based systems for serious game. This thing combined with the scene generation and component connection will look like shit on Java. Unity has this implemented, but it's super basic and once again you cannot merge this things into version control.I don't know why people still use Java today. Maybe some big corporation that has no other choice. You have PHP and Node for the server, C++ is more powerful than ever. JavaScript is a killer and UI is mostly done in HTML.When you work several years in the industry you will understand me. If you just want to make some game use Unity. It will teach you some basics about the game development. This is not very practical, when you are Ubisoft or EA and you make game with hundred of people involved, but it works and it's easy.

What are the most common mistakes novice programmers make?

Biggest one every dev makes; not undsrstanding what source code management tools are for, and how to use it.A lot of it comes down to naivety and ignorance, which is quite natural for new developers. When I started over 10 years ago there was CVS and SVN, both were pretty poor at distributed source code management, let alone functionable.A fair bit of it comes down to senior people teaching and explaining.Another one that all young developers make, is in an attempt to show how skillful, creative and valuable they are, they unnecessarily over complicate, or attempt to over engineer tasks and projects that can be solved using trivial means.A third is lack of documentation and terrible communication. Developers are notoriously bad communicators and unless you work for yourself, or become a stakeholder in some project, your communication may never exceed 6 word sentences. I've seen guys with 15 years experience pick up a task in JIRA, say “doing it" and 4 days later write “done. Passed testing.”. What did they do? What did they test? What was the cause and what on earth did they code?!My biggest issue, and one that often leads to signigicant refactoring, is the lack of standards and naming conventions. Now, we don't want all young devs being robots, they have to think creatively on their feet and propose ideas, ask questions, and learn as much as possible (my philosophy as a leader is that no question is a dumb question, but if you're asking the same, you're not understanding something). But at the same time, standards have to be maintained.That means after learning why you should use natural english naming conventions, put it into practice. Stop naming function scope variables “i" or “it" or “dCy” or some 4-6 letter interpretation of a 12-14 letter concatenated stream of words. Use the 12-14 characters! Same goes for class and function names.Anyone that's worked at a bank can pull up a dozen examples without trying of some poor sap using absurd naming conventions, trying to be smart and over complicating “Foo". Name it “Foo"!

What happens when an array with a specified size is assigned with values more than the specified size?

What happens when an array with a specified size is assigned with values more than the specified size?In C, nothing happens, because array values cannot be assigned.If you mean initialization rather than assignment, then that’s a constraint violation, meaning that any conforming compiler is required to diagnose it. (The diagnostic may be a non-fatal compile-time warning.) An example of this is:int arr[2] = { 1, 2, 3, 4 };
If you mean indirectly assigning an array using memcpy or memmove, attempting to copy past the end of any object has undefined behavior. The compiler is not required to diagnose the error, and the run-time behavior can range from doing nothing to crashing your program to yielding arbitrary incorrect results. It’s up to the programmer to avoid doing that.

How can I reduce TLE errors in CodeChef?

Why ?The online judge allocates resources like memory and CPU for evaluating every submission. However, to ensure that your submission does not keep running for an infinite time, the online judge has to stop your submission from running after a particular time period ( provided by the problem setter ).Once the submission program runs for time period the judge system issues a system kill command to the program execution and assigns TLE result to the submission.SolutionThe most common reason that you would get a TLE is because your program is too slow. Read the constraints carefully before writing your program.Try to figure out the algorithm which will make your program run the fastest.For this , analysis of algorithms is very important . Analysis of AlgorithmsConstraints even provide a basic idea for the algorithm to be used .Some basic constraints and the safe time complexity :For N <= 10 : O(2^N) and O(N!) For N <= 100 : O(N^3) For N <= 10^3 : O(N^2)For N <=10^5 O(NLogN) [ Sorting/Greedy Algo]For N <= 10^6 : O(N) For N <= 10^9 then O(logN)The second most common cause of TLE is that your method of reading input and writing output is too slow.In Java, do not use a Scanner; use a BufferedReader instead.In C++, do not use cin/cout - use scanf and printf instead.Note: Online judges may be slower than your computer. It is common for a program to take 2-3 times as long on an online judge as it does on your computer. The time limits are all attainable(tested by the problem tester).Sources :1) tle : Why do I get a Time Limit Exceeded?2) Time Complexity Analysis : Analysis of Algorithms3) Operations per second : Codeforces

What is wrong with the following Java code that replaces an empty space with '%20'?

You can just dostring = string.replace(" ", "%20");If you really are given an array of characters that are passed in, you can just do the following to get a string.String s= "";for (char c : charArray) s += String.valueOf(c);Also, I believe you want to change it to %20, not 20% (%20 is a space).             input[--newLength] = '%';             input[--newLength] = '0';             input[--newLength] = '2';That part would be incorrect.The array manipulation is really messy in addition to using the predecrements. I suggest not using those to make your code more readable.

Why am I getting errors in this C code?

Your problem is in the line:int x[3] = {1 2 3};
You can not use a space character as a separator in the initializer list. It needs to be a comma here. So, the correct line would be:int x[3] = {1, 2, 3};
My compiler insists on telling me: “[Error] expected '}' before numeric constant”, which isn’t really helpful I know, but that’s one of the things you’ll need to get used to.The compiler tells me though, that the problem is in line 6 column 16, which in my case is exactly at the number ‘2’. Which IS helpful, as you then know where to START searching for the problem. You’ll find it quite often in the line the compiler tells you or ABOVE the line. So, start searching at the line of the error message and work your way backwards if you can’t find it.And be aware, that compiler error messages are not always all that helpful.

TRENDING NEWS