Guru3D.com Forums

Go Back   Guru3D.com Forums > General > Programming/Html
Programming/Html C++,Visual Basic,HTML,Flash,OpenGL,Modelling,Java.



Reply
 
Thread Tools Display Modes
How can I make this work? (Please Help)
Old
  (#1)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default How can I make this work? (Please Help) - 07-13-2015, 04:11 | posts: 52

fdfsdf

Last edited by rakee18; 07-13-2015 at 23:20.
   
Reply With Quote
 
Old
  (#2)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-13-2015, 08:14 | posts: 52

please help
   
Reply With Quote
Old
  (#3)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 15:23 | posts: 3,507 | Location: Moscow, Russia

Quote:
Originally Posted by rakee18 View Post
So my question is how do i make a loop for the growth of the bacteria and catch the maximum number?
In case the growth is increasing from the start and at some point starts to decrease you declare the var outside of the loop like
int maxGrowth = 0;
and at each iteration of loop compare this var with current growth. In case current growth is greater than maxGrowth you save current one into maxGrowth. Else in case maxGrowth is greater than current one the population has started to decrease and maxGrowth contains the maximum.
   
Reply With Quote
Old
  (#4)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 15:55 | posts: 3,507 | Location: Moscow, Russia

Btw, your function is in trouble:

because n == 0 (always) - hence the loop will not iterate at all and function will always return 0.
Also are you sure the t needs to be incremented twice per each loop iteration - in for() and in loop body?

And in function growth you did not initialize var growth:

and in case temp == 37 which value will be in growth?

Last edited by mbk1969; 07-13-2015 at 23:14.
   
Reply With Quote
 
Old
  (#5)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-13-2015, 16:16 | posts: 52

Yes I took the loop out of the function.
   
Reply With Quote
Old
  (#6)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 16:29 | posts: 3,507 | Location: Moscow, Russia

Function to calculate the rate of change of the k

Initial value for the k is 0.1

And with every generation k will be icreased by the value calculated in calculate_k_rate().

Initial number of bacterias in population No is 1.

Last edited by mbk1969; 07-13-2015 at 23:15.
   
Reply With Quote
Old
  (#7)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-13-2015, 16:42 | posts: 52

Thanks. Can you tell me how can i get the max population?
   
Reply With Quote
Old
  (#8)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 16:43 | posts: 3,507 | Location: Moscow, Russia

So the loop should look like:

Because No is equal to 1 we can omit it -> N = e ^ ((1-k) * t)

And loop is iterated while N > 0 becase N == 0 means the population is dead.

The total time of population`s life equals to t * 20 (minutes).

Edit: Updated the code to create the t outside the loop because not all compilers let to use the variable created in the for() outside the loop.

Last edited by mbk1969; 07-13-2015 at 23:15.
   
Reply With Quote
Old
  (#9)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-13-2015, 17:12 | posts: 52

Im getting an error for loop intial declaration in c99 mode.
   
Reply With Quote
Old
  (#10)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 17:15 | posts: 3,507 | Location: Moscow, Russia

Paste it here
   
Reply With Quote
Old
  (#11)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-13-2015, 17:27 | posts: 52

hggfdg

Last edited by rakee18; 07-13-2015 at 23:19.
   
Reply With Quote
Old
  (#12)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 17:32 | posts: 3,507 | Location: Moscow, Russia

Function total() returns not the maximum of population but the number of the generation with maximum population.

You can print the maxN and maxT and t inside the total() (after the loop).

Also you can print the value of rate inside calculate_k_rate().

Last edited by mbk1969; 07-13-2015 at 17:38.
   
Reply With Quote
Old
  (#13)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-13-2015, 17:42 | posts: 52

Quote:
Originally Posted by mbk1969 View Post
Function total() returns not the maximum of population but the number of the generation with maximum population.

You can print the maxN and maxT and t inside the total() (after the loop).

Also you can print the value of rate inside calculate_k_rate().
oh okay.
   
Reply With Quote
Old
  (#14)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 17:49 | posts: 3,507 | Location: Moscow, Russia

My error - here is revised code

For con==8 and nut==3 and cel==37 it should return 0.005.

Last edited by mbk1969; 07-13-2015 at 23:16.
   
Reply With Quote
Old
  (#15)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 17:58 | posts: 3,507 | Location: Moscow, Russia

Alternative variant - with abs()

Last edited by mbk1969; 07-13-2015 at 23:16.
   
Reply With Quote
Old
  (#16)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-13-2015, 18:02 | posts: 52

Yes calculate for k is okay but I think theres something wrong with the maxT maxN function. max t is 42 instead of 41 and n is 0.0000
   
Reply With Quote
Old
  (#17)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 18:05 | posts: 3,507 | Location: Moscow, Russia

Place the whole code again (or change the post with the old one).
   
Reply With Quote
Old
  (#18)
rakee18
Member Guru
 
Videocard: Asus GTX 580 Matrix
Processor: Coire i7 920
Mainboard:
Memory:
Soundcard:
PSU: 850 watt dell
Default 07-13-2015, 18:09 | posts: 52

Thanks

Last edited by rakee18; 07-13-2015 at 23:18.
   
Reply With Quote
Old
  (#19)
mbk1969
Ancient Guru
 
mbk1969's Avatar
 
Videocard: GeForce GTX 970
Processor: I7-4930
Mainboard: Asus p9x79
Memory: G Skill RipjawZ, 16GB
Soundcard: Onboard + FiiO E17
PSU: 1000 W
Default 07-13-2015, 18:22 | posts: 3,507 | Location: Moscow, Russia

I have changed the time from hours to minutes.

Last edited by mbk1969; 07-13-2015 at 23:17.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com
Copyright (c) 2017, All Rights Reserved. The Guru of 3D, the Hardware Guru, and 3D Guru are trademarks owned by Hilbert Hagedoorn.