- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 39
- Posts with Upvotes
- 29
- Upvoting Members
- 19
- Downvotes Received
- 3
- Posts with Downvotes
- 3
- Downvoting Members
- 3
a technology enthusiast and a passionate coder
Re: @nbaztec and others I think the main loop that checks for primes can be iterated from: [CODE]for (int i = 2; i <= n/2; i++) //where n is the number to be checked for[/CODE] I think it'll be a bit faster. And also, using break may also reduce unnecessary iterations. | |
Re: Are you sure your commnad prompt says like this: c:\>myWork>javac Example.java c:\>myWork>java Example ? | |
Re: It is possible. What do you think should be the strategy? It looks like a homework question, so we'll only provide hints. But first think of something yourself and we'll help you build on it. Also, please specify what your input files look like so that we have an idea … | |
Re: Please be more specific... is it a user defined function or a standard function like, say, strncpy()? Most of the standard functions of C are available in C++ but a few C++ specific functions won't be available to C and you cannot use them in C. Please give more details. | |
Re: Also, you would like to print array[0] to array[4] to get the first 5 values :) | |
Re: @meowmonkey: can you post your solution (if that's not a problem!) so that we can have a look if what you did was indeed the best that could have been done... Well, you asked for the best way and having 3 levels of iteration (for->while->for) doesn't sound quite optimal... | |
Re: @general2012: why did you start 2 threads for this? I have replied in similar lines as AncientDragon in the other [thread](http://www.daniweb.com/software-development/c/threads/443264/copy-string-into-a-structure). Check that out for the printf problem as well... Along with not using gets, you should also not cast the output of malloc() and you should make a habit … | |
Re: Example: int fib (int n) { if (n <= 1) return n; else return fib(n - 1) + fib(n - 2); } But the iterative approach is much better in terms of complexity! That is, for large n's the iterative version will be much faster than the recursive one. Well, … | |
Re: Why its not working: 1. p->count is never initialized to anything. But the main problem is this: 2. You are trying to copy a C-string to a character. p->name[*any index*] refers to a single character and not a C-string. So strcpy fails. 3. Again, you want to print a C-String … | |
Re: > Could you guys help me solving this? :) Offcourse! But first, you need to show us some proof of efforts (that's DaniWeb rules, btw) Try to read up on arrays in the Java (Oracle) [tutorials](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html), and come up with something yourself. We'll help you build on that... | |
Re: > then why is there even a namespace? That's there so that YOU can use your own namespaces. In large programs, you may face name conflicts (especially if you're just a part of a 100 developer team!). To avoid that you may have custom namespaces for convenience. > so why … | |
Re: What have you done so far? If you haven't, then start on something. We are not here to do your homework. We are here to help you in case you get stuck. | |
Re: You are NOT using StringTokenizer to merge the 2 arrays into the 3rd. You are using it to read the 2 arrays from a txt file. In that context, your strategy will depend on the way the data is distributed in that txt file. As far as the merging is … | |
Re: > I have completed the objective Show us the **proof** (its DaniWeb's policy) and we'll be more than happy to comment on effectiveness and the rest... | |
Re: Okay, first of all that apparently meaningless output is NOT representing "1" in any language, not even Klingon :) As James mentioned, the part after `[B@` is an *unique* ID for the array so every time you recompile your code its gonna print out something different. Now, `"1".getBytes()` returns a … | |
Re: Probably this is what you're looking for: public class numbers { public static void main(String[] args) { final int N = (args.length); for (int i = 0; i < N; i++) System.out.print(args[i]); System.out.println(); System.out.print('\"'); for (int j = 0; j < N; j++) { System.out.print(args[j]); // this will give a … | |
Re: Think about it and come up with something yourself. We need to have proof of your efforts in order to help you. Show us what you've done so far and we'll help you from there... | |
Re: Dude, I told you once to stick to a single thread. Initially you had two threads for this...now you've made 3! As far as the calculations are concerned, why don't you calculate for some test cases and see if your code is giving you the same result or not? | |
Re: **@MistaGeorge:** that's correct. A parent cannot inherit from subclass. Having said that, just for the sake of availability of a 2d array you may not need an inheritance structure. Share your class design or atleast tell us what you're trying to design so that we can guide you better. **@jalpesh_007:** … | |
Re: If your class has covered functions by now then please use them. Structure your code so that you don't mess up your main. Its like delegating works to helpers. Have separate functions for average, standard eviation and others (if you can think up some) and call those methods from inside … | |
Re: We all can help...that's why we are here... but we don't help people who doesn't show any effort... and **we don't do your homework**. That's not DaniWeb. Try to think of some logic to solve the problem and we will certainly help you build up on it. | |
Re: pakArtikel method is already receiving an article as a parameter. So why make a new Article? You can simply use this: public void pakArtikel(Artikel artikel) { Basket myBasket = new Basket(); myBasket.add(artikel); } If you really want to use a new article then those <suitable parameters> would be the various … | |
| Re: You never calculated total time. The variable `TimeRequiered` simply calculates the time for each change and when you print the value outside the loop it prints the last value. To calculate total time first initialize the variable `TimeRequiered` to 0 at the beginning. Then change line# 44 to TimeRequiered = … |
Re: How does the Sorting.insertionSort() method look like? Is it from any standard API? | |
Re: You are moving the temp to temp next before and then trying to print temp's variables! That's why you're getting all garbage! You should move line# 29 and 30 between line# 34 and 35. But that's not the only problem! You're reading off the first line using getline! The inFile … | |
Re: What is your expected output and what are getting now? Please specify the error(s). A few observations at a glance: If you're using any standard compiler, your code may not compile. 1. Use `#include <iostream>` (no .h) 2. Same for `#include <string>` 3. Also, specify main to be returning int … | |
Re: what errors are you getting? for writing main: [see this](http://lmgtfy.com/?q=java+method+calling+example) | |
Re: for running an app you do not need a compiler. You can simply take out the .exe and share it. It'll run, but given the fact that you're using "Turbo C++" it might not run as you would've expected it to, on a few machines. A few advice: * Get … | |
Re: Define a string somewhere and call it whatever... i called it str...then inside that loop use this: // for the last word, no comma afterwards... if (i == (aa5.length - 1)) { str = str + aa5[i]; } else { str = str + aa5[i] + ", "; } | |
Re: Which compiler? And which platform? It works as its supposed to in Visual Studio 2010 (i used the command line tool) on a Windows machine. I think, if you're on \*nix, along with that `cin.ignore(cin.rdbuf()->in_avail(),'\n');` you also need a `cin.ignore(cin.rdbuf()->in_avail(),'\r');` I'm not sure, but intuition tells me that it has … |