I wrote the following code to test which is faster: performing a multiplication and division many times, or accessing the results in a vector via iterators(perform the calculations ahead of time), or hard coding the results of those calculations into the program. I actually expected storing the results in the vector to be faster than performing the calculations, but on my system I get the following relation for the times to complete each corresponding function: Hard Coded Values < 5 * (On the fly calculations) < 50 * ( Vector Stored Values) So my question is this: Am I stuck …

Member Avatar
Member Avatar
+0 forum 11

Basically, i've been told to initialise a grid into the "canvas" section of this program i've made, I need to make a fine grid that stretches across the whole canvas horizontally and vertically, 10 x 10 pixels apart example of the code i'm editing to do this below... [CODE] class Canvas extends JPanel { // Called every time there is a change in the canvas contents. public void paintComponent(Graphics g) { super.paintComponent(g); draw(g); g.setColor(new Color(0.8F, 0.8F, 0.8F)); g.drawLine(10, 800, 10, 10); g.drawLine(20,800, 20, 10); g.drawLine(30, 800, 30, 10); g.drawLine(40,800, 40, 10); g.drawLine(50, 800, 50, 10); g.drawLine(60,800, 60, 10); g.drawLine(70, 800, …

Member Avatar
Member Avatar
+0 forum 7

""" Write a function to convert temperature from Celsius to Fahrenheit scale. oC to oF Conversion: Multipy by 9, then divide by 5, then add 32. Examples >>> Cel2Fah(28.0) '82.40' >>> Cel2Fah(0.00) '32.00' """ so it says, but i couldn't think of an a way to do so efficiently. But none the less, i felt i should try it and then look up a better way after the code i wrote is as follows; [CODE] def Cel2Fah(temp): Fah = temp * 9 / 5 + 32 Fah = float(Fah) Fah_string = str(Fah) a = Fah_string.split('.') b = a[1][0:2] if len(b) …

Member Avatar
Member Avatar
+0 forum 2

Hello everyone, I have created my own random text generator with a custom method, no Markov chains included, and now I would like to try it on a different text corpus that is larger from that of NLTK's and I wanted to know which Data structure should I use in order to make the code work faster since additional text files will surely make the code a painstaking procedure to execute. My algorithm is as follows: 1- Enter the trigger sentence -only once, at the beginning of the program- 2- Get the longest word in the trigger sentence 3- Find …

Member Avatar
Member Avatar
+0 forum 2

I found [URL="http://www.daniweb.com/software-development/cpp/threads/358674"]this assignment[/URL] on C++ forum as was browsing to see little where I am in my mostly C little C++ thrown in understanding of C++ and if I should try to increase my knowledge in that language. I could not believe my eyes! The OP is completely lost what to do and what approach to take and do not finish in time. Ok, we must consider that I have read this post for main points before but I do one experiment. [LIST=1] [*]I paste the description on this post and log the time [*]I write the function for …

Member Avatar
Member Avatar
+0 forum 6

The End.