|
|
Subject:
Generate Set Randomly
Category: Computers > Algorithms Asked by: xtrashock-ga List Price: $20.00 |
Posted:
21 Nov 2006 14:34 PST
Expires: 21 Dec 2006 14:34 PST Question ID: 784604 |
How can I write a function (prefer in perl/php language) to return a set of items based on following input arguements? min. number of items to be generate (at least 1 item) max. number of items to be generate (at least min. items) average value of items (each item assigned a value from 1 to 5) | |
| |
|
|
Subject:
Re: Generate Set Randomly
Answered By: keystroke-ga on 09 Dec 2006 12:15 PST |
Hello xtrashock, Thank you for your question. I am going to write you the pseudocode for this: ------------------------------------------------ 1 Accept input from command line or other input device 2 parse command line and find minimum item amount and maximum item amount. 3 if minimum item < 1 then display error "minimum items must be more than 0 4 if maximum < minimum or maximum <1 then display message "your maximum level is incorrect, it must be greater than minimum and also greater than 0. 5 if all arguments are correct in a for loop structured as for x = min to max do print generated item 6 after each item is generated add the value to a counter that is keeping a sum of the total values, 7 after each item has been generated calculate average using the following funtion average = value total / max items 8 display average 9 end program run Search strategy: Personal knowledge This should answer your question. If you need any additional clarification, let me know and I'll be glad to assist you. --keystroke-ga |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |