Forum: C May 10th, 2007 |
| Replies: 13 Views: 2,659 Hey niek, thanks for the code critique. I have included a new variable to contain the value returned by the binarySearch function. However I'm not sure what you mean by I'm only calling the... |
Forum: C May 8th, 2007 |
| Replies: 13 Views: 2,659 Thanks sos. Now the program finds all the numbers in the array... the only problem is that it also finds numbers that aren't in there, and even letters. Which suggests that the binarySearch function... |
Forum: C May 7th, 2007 |
| Replies: 13 Views: 2,659 Right, so I have written a few new functions, including one for the binary search as suggested. Annoyingly, it is this same function that I can't get to work... At the point where I call it in int... |
Forum: C May 7th, 2007 |
| Replies: 13 Views: 2,659 And on looking at the code again, I realise that all I might be needing is an if statement that says if the number entered is equal to the mid (i.e. the 3rd item in the array), then to just print... |
Forum: C May 7th, 2007 |
| Replies: 13 Views: 2,659 Hi sos, thanks for the tip + link, I have incorporated both things into my program, and it seems to work, except that when I search for the 3rd item in the array, the program just terminates - it... |
Forum: C May 6th, 2007 |
| Replies: 13 Views: 2,659 OK, I've indented the code, and put print statements in the Binary Search algorithm part of the code. The algorithm seems to recognise when a number is higher than or lower than the middle point, but... |
Forum: C May 5th, 2007 |
| Replies: 13 Views: 2,659 Hello once again people; I hope I'm not breaking any rules or being cheeky. But I was searching for algorithms/programs on the internet that would help me with my binary search program, and then I... |
Forum: C May 5th, 2007 |
| Replies: 24 Views: 9,716 Thanks very much people, I am now timing my programs using clock(). Seems to give fairly decent graphs, although I think I need to run the programs more often to get a better average.
Still, all... |
Forum: C May 4th, 2007 |
| Replies: 24 Views: 9,716 Ah right, interesting. Well I use MS-Windows too, but I have to run my C programs through the compilers on the Unix servers at my universities. Which I guess means I'm sort of working on unix doesn't... |
Forum: C May 4th, 2007 |
| Replies: 24 Views: 9,716 I've added an adaptation of this into my program. I print out cpu_time_used in floating point format. Is this value in seconds, because I have divided by CLOCKS_PER_SEC? |
Forum: C May 4th, 2007 |
| Replies: 24 Views: 9,716 Thanks everyone for all your posts. Will try different solutions and see what works. Thing is, does the fact that noone has mentioned getrusage() mean that noone here uses it? |
Forum: C May 3rd, 2007 |
| Replies: 24 Views: 9,716 Hello again people, I've got some questions about timing that I hope can be answered by someone.
I'm trying to use the functions getrusage or times, or the time command to time my programs. Now... |
Forum: C Apr 29th, 2007 |
| Replies: 10 Views: 1,766 Hehe, I get it.:P. Was just being a bit too curious. |
Forum: C Apr 29th, 2007 |
| Replies: 10 Views: 1,766 Hi there, I just wanted to say, I think you all are making very valid points, and I think it's just unfortunate that some people don't use decent grammar in forums and seem to ask people to do their... |
Forum: C Apr 29th, 2007 |
| Replies: 17 Views: 18,073 Yes, that IS a useful thread, thanks again! |
Forum: C Apr 29th, 2007 |
| Replies: 17 Views: 18,073 Again, apologies, so embarassing, I solved the 2nd qstn, I have to use the same value in lines 11 & 13 if I'm going to use something different from 'available'.
Thanks v much for all your help... |
Forum: C Apr 29th, 2007 |
| Replies: 17 Views: 18,073 Yea you're right, now it works. Thanks so much, you've been amazing. But may I please ask a couple more things: "--required" decrements that variable so that the number entered into the function is... |
Forum: C Apr 29th, 2007 |
| Replies: 17 Views: 18,073 Hmmm. I've put 1024 in there, and it sure prints out a lot of numbers, which might well be 1024 numbers. But when I put in 10, it prints out 98 numbers, and when I put in 5, it prints out 50 numbers.... |
Forum: C Apr 29th, 2007 |
| Replies: 17 Views: 18,073 OK, I'm being silly, this is the correct version of the code that compiles and runs.
#include <stdio.h>
#include <stdlib.h>
int i;
void generate_ascending_number(int n)
{ |
Forum: C Apr 29th, 2007 |
| Replies: 17 Views: 18,073 Hey vijayan is that C++, because I'm using C..?
I guess I can try to convert most of it though, afterall it's only an algorithm, shouldn't be too hard right??
After typing out code...
Err,... |
Forum: C Apr 29th, 2007 |
| Replies: 17 Views: 18,073 Hey Aia, I guess I am assuming that if I start from zero, then I can keep generating random numbers, telling the program which ones I want to keep & print to file i.e. the one that is larger than the... |
Forum: C Apr 29th, 2007 |
| Replies: 17 Views: 18,073 Thanks Lerner,
I DO want to have the same random sequence each time I run the program so I think for now I don't want to seed rand(). And I do know a bit about sorting, but I'm not allowed to use... |
Forum: C Apr 25th, 2007 |
| Replies: 17 Views: 18,073 Thanks Dragon, I did that, and I got 26 of the 50 numbers printed out on the screen, and the remaining 24 printed out to the file. The first number printed to the screen is '0', but all the numbers... |
Forum: C Apr 25th, 2007 |
| Replies: 17 Views: 18,073 Hey, I'm hoping someone can help out here. I'm trying to use the rand() function to generate sequential random numbers in C, and then write them to file. Now I know it's possible, I'm just not sure... |