Infarction 503 Posting Virtuoso

oh... didn't realize you could make it play the DRMed ones. Got a link for how to set that up?

Infarction 503 Posting Virtuoso

Thanks but I figured it out

boolean result = false;
int row = 0;
int col = 0;
for (row =0; row<theArray.length; row++){
   for(col = 0; col<theArray[row].length; col++){
   if (theArray[row][col]== value)
    result = true;
}
}
return result;

Perfect. I'll just suggest one change here, but it's probably something you don't need to worry about: if you have a huge array (say, something like theArray[1000][1000]) and the first item is a match, you'll still check all of the million things in the 2D array even though you've found a match. There's two easy ways to get out of this, and which to use is up to you (there's reasons for each). First, you can just return once you've found the match:

for(/*...*/){
   for(/*...*/){
      if(theArray[row][col] == value)
         return true;  // gets out of the loops (and the function)
   }
}
return false;

It should be fairly easy to see how this gets the right result and why it's more efficient. Another way to do it is a tad more jumbled and fancy, and involves labels (which can be a touchy subject). It looks something like this:

outerLoop:
for(/*...*/){
   for(/*...*/){
      if(theArray[row][col] == value){
         result = true;   // same as yours
         break outerLoop; // breaks the outer loop and goes to the return
      }
   }
}
return result;

Notice the outerLoop: before the first loop. As of Java 1.5, you can use labels like this to break or continue a specific loop instead of having these inefficiencies.

Infarction 503 Posting Virtuoso

Ive sorted out the dlls i need for VLC to play WMAs...

Sorted out the dlls? Why would you need to do that?

Infarction 503 Posting Virtuoso
int row = 0;
int col = 0;
for (row =0; row<theArray.length; row++)
{
   for(col = 0; col<theArray[row].length; col++)
   {
       // no work being done here...
       // you should compare theArray[row][col] with what you're 
       // searching for and you can return if it's a match
   }
}
if (row == col) // row and col were the array indices, why compare them?
    return false;
else
    return true;
Infarction 503 Posting Virtuoso

I think it's just another scapegoat for people so they don't have to take responsibility for themselves...

Infarction 503 Posting Virtuoso

I would bring into question your programming needs. Most HLLs will tradeoff optimal efficiency for greatly reduced development time or increased code readability. Furthermore, assembly will limit your program to a specific architecture and OS, whereas with Java for example, you can take your code (or your .class file) and run it anywhere with a JVM.

Infarction 503 Posting Virtuoso

Look through the files for a try-catch block for an IOException and an output message matching what you've shown us. We can't really do much without seeing the code or where the error is coming from.

If you have more than one catch block with that message, you can trace it using something like this:

catch(IOException e){
  e.printStackTrace();
  // whatever else here
}

and it'll tell you where the error is happening.

Infarction 503 Posting Virtuoso

The error would be helpfu for us to help you, but lemme give this crystal ball a try...

You never initialize cString, so it's just pointing to some random place in memory. Then you try to read from the file into that place in memory. When that happens, you get an access violation (in VC++, it probably says something about address 0xC0000005 or something). You need to initialize cString before you write to it.

Might I ask why you don't just the std::string class? It would allow you to proceed without the hassle of initializing the variable (initializing is a good habit though), and it would also make sure you don't read in something that would cause a buffer overflow. Like if someone had a text file with the word pneumonoultramicroscopicsilicovolcanoconiosis, if you're expecting something shorter it's fairly likely that your char* won't be big enough and you'll get another access violation.

Infarction 503 Posting Virtuoso

well, I got 140 so I can't complain too badly. But by the last 5 I was really not caring much. How do they get your IQ based simply on pattern matching? And why is there only one correct answer for each one? Seems like people would process things differently, at least with images, so it'd be hard to measure with any degree of accuracy.

And if anyone wants a perfect score, the source code has it all (I checked before submitting :p)

Infarction 503 Posting Virtuoso

When your code is compiled, it is tailored for a specific environment (e.g. operating system, or certain library support). You can't just create a binary that'll run on anything, anywhere.

Infarction 503 Posting Virtuoso

You probably would be best to look into a threading library and make your program multi-threaded.

Infarction 503 Posting Virtuoso

I recommend that you start with standard C/C++ like joeprogrammer mentioned, and just get used to the language and its constructs. Afterwards you can familiarize yourself with specific libraries if you so desire.

Infarction 503 Posting Virtuoso

As far as I know, WMA can't natively be played on Linux due to propretiary Microsoft codecs. If you want, you can install Wine and use it to run Windows Media Player. For MP3s, you should have a default player instalelled, although you may want to find a better one.

I think WMA format is fine (given the right codecs) but DRM'ed files won't work. All my files are .mp3 though, so I can't say for sure...

iamthwee commented: ty +6
Infarction 503 Posting Virtuoso

I got my license first thing on my 16th birthday. Even sat outside the Dept. of Licensing office till they opened. :D

Infarction 503 Posting Virtuoso

Haven't used Ubuntu in a while, but you install stuff either via synaptic (GUI) or apt-get (CLI). As for .mp3 support, it doesn't have it out of the box (main reason I dumped it the second time was the stuff it doesn't have by default). For nvidia drivers, there might be some in one of the repositories (you'll have to check with synaptic or apt), otherwise you might have to get them from nvidia's site. You'll probably get more specific help from ubuntuforums.org though.

Infarction 503 Posting Virtuoso

You'll want SMP. You might as well get bigmem, though I don't think it's needed for less than 4GB of memory. If you intend on upgrading to 4GB at some point, get it. I don't recall how memory-mapped I/O interferes with the memory space without bigmem...

Infarction 503 Posting Virtuoso

This page has several open source licenses you can look through. They do mostly apply to source code and/or distributed binaries, though, so you might look into maybe the Creative Commons license. I don't think this will protect you from anyone implementing your idea in actual software, however, so if you're really worried about it you might look into pursuing a patent. I'm not an expert by any means though...

Infarction 503 Posting Virtuoso

I got a 90%. I had no idea when highways were most slippery...

The reason it's most slippery at that point is because the oils from people's tires/leaks (and even from the asphalt) and the silt that's settled during the dry spell gets loose from the fresh rain and makes things slick. If it's been damp recently, that stuff will mostly have washed off, so the road won't be as bad.

Infarction 503 Posting Virtuoso

Technically, Java is forcing you to use objects but it's not fully object oriented. Smalltalk on the other hand exemplifies the OO paradigm better, since everything is an object. By everything, I mean it includes methods, data, and aggregations thereof. In Java or C#, you get data aggregations with related methods, but the methods (and sometimes the data) are not objects themselves (though they might return an object).

Infarction 503 Posting Virtuoso

95% here, missed #3 (but I hardly ever use high beams, so my answer should have counted :p). I suppose that's a good thing, since I do like to drive... unfortunately my car got totaled the day after Christmas (no injuries thank goodness), and I'm still resolving the insurance claim :(

Oh, and my drivers ed costed $400ish as I recall, for 10 driving lessons and 10 or 20 classroom lessons... that was 5 years ago as well, so I don't remember exactly.

Infarction 503 Posting Virtuoso

Here's a simple tip for you:

By adding using namespace std; to your code, you wouldn't have to type std:: everytime: cout << "hello";

There is also the issue of invoking the entire std namespace and the scoping issues resulting from that, but I s'pose that's for another discussion ;)

Infarction 503 Posting Virtuoso

yum is the package manager for Fedora Core, whereas Mepis is .deb based. Try using apt-get or synaptic. This page should cover the basics of installing packages on Mepis

Infarction 503 Posting Virtuoso

Gentoo does take a bit longer to install, but I found that the documentation got me through the minimum install pretty easily. The only big complaint I have with it is the time it takes to compile everything, but I guess that's the cost of a source based distro. And I usually just compile everything while I sleep anyways, so the wait doesn't end up bothering me ('cept for new programs). Portage is so sweet that I don't think I'll be replacing Gentoo for a long time... :D

Infarction 503 Posting Virtuoso

First question I have is why are you using doubles when you should probably be using ints?

Second question would be why is everything static? Static members belong to the class rather than to a specific object (instance of the class). The way you have it now, all the libraries would have the same books. So make those un-static.

In your second contructor (the one taking num as a parameter), what does num represent? Your code suggests that it's the number of books in the library, but I'd guess that it should be the max number of books for the library. If my guess is correct, your empty constructor should probably call the second constructor with a default value.

inLib doesn't seem like it should be in the Library class. Do you have a separate Book class? I'm assuming you do, since you try to create an array of Book1. The structure here seems a little confused. You probably want a function like public boolean isInLib(Book b) which checks if the specified book is in the library (this'll require some way to compare Book objects). The static variable inLib probably is not what you really want, since you should be checking if a specific book is in the library or not.

Similarly with the variable addNew, it's probably not needed. The method addNew() will always return true or false; however, the method should probably take a Book as a parameter as well (e.g. public boolean addNew(Book b)). And you should …

Infarction 503 Posting Virtuoso

Alright, let's see if we can't start over.

The first problem asks you to write a program where you input the distance and output the "distance as minutes." I'm guessing this means the amount of time to travel the inputted distance. In order to make this calculation, you need a speed. For example, if you're going 10 km, it'll take you longer if your speed is 2km/min than if it's 6km/min. Is this right so far?

Infarction 503 Posting Virtuoso

Ok, I think I misunderstood. As joeprogrammer pointed out, if you're supposed to output the time it'll take to travel the given distance, you'll need a speed as well. Then the time will be distance/speed. So you'll need another variable for the speed, and you'll have to input that as well.

Infarction 503 Posting Virtuoso

Just kinda wondering what distros people have run. I LOLed in the Choosing a Distro forum when people said Gentoo was the hardest distro, so I was wondering what everyone's background is.

I've had Gentoo on my laptop since April (exclusively since June) and it's the system I use most (also the first time I've really used Linux). I dual boot FC6 on my desktop, but only rarely actually use it. I've had FC 4, FC 5, Gentoo, Ubuntu 5.04 and Kubuntu 6.06 installed at various times on my desktop though.

So, how 'bout you guys? :)

Infarction 503 Posting Virtuoso

Let's walk through the code real quick:

#include<iostream>
#include<string>
#include<stdlib.h> // this should be <cstdlib>
using namespace std;
int main()
{
  int Mintues; // where is this used later?  And did you mean miles?
  cout<<"please enter the distance in kiolmeters"<<endl;
  cin>>Kiolometers>>endl; // where is Kilometers defined?
  // you probably should do the conversion here...
  cout<<"the distance in mintues is"<<endl; // you need to output your result here too
  system("pause");
  return 0;
}

You've got the basic idea, but hopefully the comments will get you the rest of the way. For the second problem it's just a matter of switching the words and the conversion factor (from 1.6 to 0.6).

For the last one, do you need to get the distance and the speed from the user, or should you just use constant values? You can approximate the distance as 93 million miles and the speed as 186,000 mi/s if you're just using constants.

Infarction 503 Posting Virtuoso

Once you have the bit string it's pretty easy. You'll just need to loop from the least significant bit (the one whose value is 1, often the right-most one) through the string to the most significant bit (the one whose value is 2^n, corresponding usually to the left-most). If the bit at the current index is 1, add 2^i, where i is the current index. For finding powers of two, you could also use the left-shift operator (number << shiftAmt), which would pretty much be 1<<i for this case. Make sense?

Infarction 503 Posting Virtuoso

We'll certainly help you, but we won't do your work for you. If you have some code that's not working right, post it and we'll try to fix it. If you don't know how to code the solution, tell us what how you think it should be solved and we'll try to help you translate it to code.

Oh, and for #3, you can use this:

#include<iostream>
using namespace std;

int main()
{
        cout << "8.3 minutes" << endl;
}
Infarction 503 Posting Virtuoso

You're really close again. You've got the assignment backwards for the first value (it should be a = theArray[0]; ). There is one other problem with your code though: it doesn't scale. What you posted will rotate the first 10 items, and the loop will cause the rotation to happen however many times there are items in the array. So if the array had 12 items, the first 10 would get rotated 12 times. And if the array had less than 10 items, you'd get an exception. Here's another way to do it:
- save the first value in a temporary variable
- use a loop to iterate over the list, making theArray = theArray[i+1] (for values of i from 0 to theArray.length-1).
- copy the temporary value into the last item in theArray.

You'll notice that you need to adjust the condition in the for loop this time to have a -1. That's because you're indexing the (i+1)th element, so without the adjustment you'd get an ArrayIndexOutOfBoundsException on the last iteration.

Infarction 503 Posting Virtuoso

B(+) trees would be just writing a data structure, which I would imagine would be a little below the scope of your project. However, you could incorporate them into a basic database engine (since that's one of the biggest uses of B-trees). That might be a little over the top, depending on your timeline...

One way to get an idea might be to think of some program you use a lot but wish it had feature X different. For example, you might want a media player with something different from what you use. It's kinda hard to just suggest something without knowing your interests and skills though...

And I would hesitate to lock yourself into a language before deciding on a project. The overhead of learning a new language might slow you down at first, but it could end up saving you development time once you get used to it. Besides, then you'd have one more language to put on your resume ;)

Infarction 503 Posting Virtuoso

What about other operating systems? There's a lot of people 'round here that'll probably prefer a *nix distribution... ;)

Oh, and Apple was the first company to coin the term PC. Now that their hardware is basically the same as an "IBM-compatible" PC, you might consider revising your terms :p

Infarction 503 Posting Virtuoso

...which you absoloutely love because it's so user-friendly. :cheesy:

Sounds horrible :twisted:

Infarction 503 Posting Virtuoso

From the way I was tought things, function programming is synonymous with procedural programming.

You were taught wrong. From wikipedia:

Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and avoids state and mutable data. Functional programming emphasizes the application of functions, in contrast with imperative programming, which emphasizes changes in state and the execution of sequential commands.[1]

The articles on procedural and imperative programming have notes mentioning that the two terms are mostly interchangeable.

As for the "complexities" of operator overloading and pre-processor commands, I consider those complexities, because if you overload an operator, and you are developing a large application, the operator overloading can be lost in the lines, and become a serious source of frustration - something I've experienced in the past, and which has led me to keep away from C and C++. As for pre-processor commands, I just don't see a point for them aside from incorporating header files.

Operator overloading is one of the things I wish Java had. Of course, there is a matter of when it's appropriate to use operator overloading. As to pre-processor commands, they definitely have a point if you know what they do.

I'm a Lisp (primarily), Python, Perl, Java, BASIC, Expect and shell programmer by trade, and am learning Linux-based x86 assembly - all languages which have no imminent focus on pre-processor calls.

Congrats …

Infarction 503 Posting Virtuoso

Gentoo isn't all that bad except for the compile times. If you just run emerge kde , it will take a while. If you've not done that yet, you might consider using the split ebuilds.

Infarction 503 Posting Virtuoso

And which programming language?

That consideration should probably be made after the project is decided upon, and if the task of learning the language ends up being preventitive to finishing the project then you'll need to choose a different project.

Infarction 503 Posting Virtuoso

Computer science and software development should not be construed as the same thing. Software development deals with a process of designing and implementing a program, whereas computer science deals more with how computers work and how they can be made more efficient (this includes how to use them more efficiently). Computer science has largely been misconstrued as software development because so many people with CS degrees end up developing.

Infarction 503 Posting Virtuoso

There are two branches of programming: functional, and object-oriented. Functional languages leave the entire language at your disposal without having to import other "classes". The problem that arises with functional languages, is that you end up re-typing out code again and again. For instance, let's say you're creating a program that requires networking protocols like TCP/IP and HTTP. So, you spend the time writing the program, and it works perfectly. Now, you go to write another program, some time later, and you require the TCP/IP and HTTP protocols this time. You are going to find yourself re-typing or copy-and-pasting the code from the old program - this can prove to be time consuming, and perhaps even cause big errors in the code.

That's why we have libraries...

Now, with Object Oriented Programming approaches code importing a little differently. In Java, let's say, you have the option to just use the standard code base, which can keep small programs neat and tidy. But for larger applications, it starts turning into a functional approach to things - and not to mention, some things in Java just aren't possible without importing some classes. Object-Oriented Languages make use of "objects", "classes", "inheritance"...things like that. A class is an object definition, and an object is a creatable/destroyable instance of a class - it's a roundabout definition, but it's the best I can do for the moment. Inheritance allows other classes to keep their inherent functions (or, as Java-heads call them, "methods"), and expand on …

Infarction 503 Posting Virtuoso

You're definitely on the right track, but a little off. First, the array is given to you as the parameter, so you don't need to make another one. And your logic is slightly off in the if statement. Try something like this:

public int countOdds(int[] data)
{
  int oddCount = 0;
  for(int i = 0; i < data.length; i++)
  {
    if(data[i] % 2 == 1) // if it's odd
      oddCount++;        // increment the counter
  }
  return oddCount;
}

Remember that if statements have the condition in parentheses, and that testing for equality is '==' rather than '='. Also, when you go through an array, you want to index 0 to theArray.size-1; the -1 is done implicitly by using <, but if you use <= you need to make the adjustment.

peter_budo commented: Nicely explained... +3
Infarction 503 Posting Virtuoso

This is so funny
haiku phrases are one line
stop wrapping them please

Senryu and haiku differ by content. Haiku have natural themes to them and are serious in nature (see mattyd's for an example), whereas senryu often do not have the natural themes and are not always as serious (see pretty much everything else in this thread). Most people seem to think that the 5-7-5 syllabic layout is simply the definition of a haiku when it's really not.

Infarction 503 Posting Virtuoso

*nix often does not run on the same hardware as MS-Windows. For example we have a lot of linux systems that run on Sun workstations with RISK processors (I think they are RISK)

I think a more correct phrasing would be that Windows does not run on the same hardware as *nix... ;)

While the statement is true, you should also consider that Windows comes as a binary installer for x86, whereas Linux sources (which I'm most familiar with in the *nix family) have separate source codes for different architectures. For instance, here's the contents of the $(SOURCE)/include directory (where ./asm/ is a symbolic link to the local architecture):

include $ ls
acpi       asm-frv      asm-m68k       asm-s390     asm-v850    media   sound
asm        asm-generic  asm-m68knommu  asm-sh       asm-x86_64  mtd     video
asm-alpha  asm-h8300    asm-mips       asm-sh64     asm-xtensa  net
asm-arm    asm-i386     asm-parisc     asm-sparc    config      pcmcia
asm-arm26  asm-ia64     asm-ppc        asm-sparc64  linux       rxrpc
asm-cris   asm-m32r     asm-ppc64      asm-um       math-emu    scsi

You'll notice if you download an image of a linux installation (e.g. for a live CD) that you do have to choose the approriate image for your architecture.

Infarction 503 Posting Virtuoso

the sparc architecture is a RISC architecture with pipelining. the pipelining leads to real problems trying to write assembler for it if you're used to the x86 type (which i am used to)

You do realize that a Pentium 4 has something like 40 pipeline stages, don't you? Pipelining is one of the most basic ways to increase throughput on a processor, though it does add a good deal of complexity to the design.

Infarction 503 Posting Virtuoso

haiku is not weird
but this is not a haiku
this is a senryu

http://en.wikipedia.org/wiki/Senryu

Infarction 503 Posting Virtuoso

choco^2, and somewhat accurate.

And I agree about the cake brownies sounding wrong, though they wouldn't have been my first choice anyways

Infarction 503 Posting Virtuoso

You'll need to be consulting documentation for those. Most of the time, all of those functions will already be compiled into libraries, and your linker will reference the libraries when it puts your program together.

Infarction 503 Posting Virtuoso

always lived in the same neck of the woods... it be listed in ye olde profile if you can't find it... :p

Infarction 503 Posting Virtuoso

Purple Avenger's reply mentions some good points, but fails to describe how pipelining actually works. If you think of a basic (naive) design for a processor, you'll probably have it read an instruction from instructional memory (or cache), parse the instruction, read register values from the register file, send those values to an ALU, send the ALU result to a stage for memory I/O, and send the result there (if not a mem op, then no change) back to the register file to save. The total time for this can be quite long.

Now suppose that we know that the ALU takes 1/3 of the total time to handle one instruction (this is a fictional example btw). If we cut the processor into independent section as mentioned above, with state registers for passing values between them, we can reduce our clock period to 1/3 of it's original (or triple the frequency) since that's the longest period needed for an intermediate stage. For any given instruction, it will take just as long to compute; however, you can have n instruction computing separately along the pipeline (where n is the number of pipeline stages). End result is that you get a faster speed.

For crazy designs (aka whatever's in your box most likely), there will be many pipelines and multiple data paths, both of which are essentially multipliers in both computing output and design complexity.

There's more info from Wikipedia but I'll admit I didn't actually read …

Infarction 503 Posting Virtuoso

>>If we confine our discussion to x86 hardware
claiming a program is portable makes no such restriction, and neither do I.

I believe Evenbit's argument arose from this phrase, which implies a focus on OS rather than hardware:

If you are looking for portability between operating systems, such as *nix and MS-Windows, then you should stay clear of assembly -- it ain't portable.

Infarction 503 Posting Virtuoso

I'm thinking your circular queue is more complicated than it should be. Here's how I would write one:

struct circular_queue
{
  someFormOfData** data;
  int head, tail, count, size;
};

void insert(ciruclar_queue* q, someFormOfData* d)
{
  if(count == size) // it's full
  {  growTheQueue(q) }
  q->data[q->tail++] = d; // add the new data
  q->count++; // update the count
}

someFormOfData* remove(circular_q q)
{
  if(count == 0) // it's empty
    return NULL;
  q->count--; // reduce the count
  return q->data[head++]; // return the value
}

void growTheQueue(circular_queue q)
{
  // make a new array with more room
  someFormOfData** newData = (someFormOfData*)calloc(q->size * 2, sizeof(someFormOfData*));
  // copy the data
  for(int i = 0; i < q->count; ++i)
  {
    newData[i] = q->data[head + i];
  }
  // update the values in the struct as appropriate
  free(q->data);
  q->data = newData;
  q->head = 0;
  q->tail = q->count;
  q->size *= 2;
}

Just wrote this, didn't compile or test it at all. Hopefully it gives you an idea of how it could be written. I left out init, because that's trivial.