you're forgetting that we're allowed to have just one recursion. if we've computed the sum, we have no recursion left to traverse the array. So theres got to be another solution.
but no matter...
Type: Posts; User: mkruk
you're forgetting that we're allowed to have just one recursion. if we've computed the sum, we have no recursion left to traverse the array. So theres got to be another solution.
but no matter...
I copyed and pasted your code and compiled it as it is shown. And it returns 5.
mk@mk:~$ cat test.c
#include <stdio.h>
int max_seq(int *arr, int i, int last, int len);
int main()
{
...
my first idea is to get the sum and divide it by 2. now we have the sum for both partitions.
Then I'd traverse the array and check if I can substract elements until I get zero.
nah. you have written two functions and the first one calls the second. If I understand that condition correctly, then the task was to have only a single function which calls itself.
edit: damn,...
you're using one of those :p
anyway, I don't think its possible to make the function any shorter than 5 lines without making the code unreadable
you're welcome :)
I've had quite some fun thinkin about how to make the solution as short as possible. I'm a minimalist
duh.. because you can just put 8 numbers into an array of size 9
#include <stdio.h>
int max_seq(int *arr, int i, int last, int len)
{
if(i > len)
return(0);
int eval = (i == 0 ?...
its actually very simple.. for every cell you check
a) if theres a bigger sequence starting at the next cell
b) if that sequence is bigger than the sequence starting at this very cell
if we're...
oh god you can't be serious :D
I tried to implement it and it isnt very difficult. My implementation is all recursive, exactly as you require it to be and its just 5 lines of code (not counting...
in the first place, I'd check with lsof if some process locks the file "/afs/ir/users/l/i/lizb1/.iCE authority."
the next step would be checking the permissions of the directory and the file. If the...
as already pointed out, the problem is in line 1 of your main() function. What you have there is actually a multidimensional array, which conflicts with your declaration of the readLine() function. ...
how did you code the delay? are you sure it delays by one second?
if it does, how do you establish the connections? is there something else writing to the sockets?
like matsp mentioned, I'd be...
INADDR_ANY is not supposed to be a remote destination; its for listening sockets. using it on a client socket has the same effect like using 127.0.0.1, but has the side effect of making your code...
sounds like a fairy tale to me...
the Arctic isn't USA. You were talking about US oil reserves.
Still, drilling in the Arctic could be difficult because of the temperatures. And isn't there a...
no, I was saying that the USA using their own oil is nonsense. With increasing demand for cars this might actually be 2 years or less.
I totally agree that, on the long run, oil is not a reliable...
I doubt that.
As a little proof, let's look at some statistics from wikipedia:
According to this, USA produces 8.481.000 barrels of crude oil per day (yes, crude oil.. so the amount of usable...
As far as I know, the whole EU is planning to do this. Well, actually not monitoring like looking what exactly someone is transfering, but logging what IPs are being connected and the amount of data...
close(new); has to be in the while loop, otherwise new will be assigned a new socket, but the old one will not be closed, thus creating more and more sockets.
this is also the problem why a client...
the easiest method is writing a webserver for that specific html page, which shouldn't be a big deal if you're familiar with html. The difficult part is, that you'll need a good understanding of the...
I think there's no such function or format string. Write a loop that prints one digit after another. A little hint, modulo is needed here. When dividing the number with 10, the remainder is the last...
I doubt this works. This will read two messages and discard the first one. Later on, this will definitely lead to unwanted behaviour
either strcmp() or loop through the string. I don't think there's another way.
And I'd prefer the latter one, if you want to filter strings like " ", " ", etc.
Even if some of them get slaughtered, they can still prevail. Look at the Bolsheviki or Ghandi
Civil disobedience is not the answer imo. Well, unless a lot of people do it.
but if not, this is just as useless as demonstrating agains carnivores or the iraq war - it just happens. (Don't get me...
The Gimp is written in C. So is Linux (except for some assembly files).
As far as I know, OpenOffice is Java, hence the JRE installation when installing OpenOffice.
I'm not sure about FireFox, it...