473,408 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

help with logic

8
hi
i am required to generate two independent data sets using random numbers.
1) first(lot sizes) can be generated with no problem.
2) second set(order size) of data should be such that the total of second is less than or equal to the total of one.
order size <= lot size
May 4 '07 #1
5 1294
svlsr2000
181 Expert 100+
You can use combination of srand and rand.

Srand is used to seed the random number generator.

Do both of them simultaneously and make sure Your secod random number is always smaller then first one before adding to repository or database.

int array1[100];
int array2[100];
int index;
srand(...);
....
array1[index] = rand();
array2[index] = rand()
if(array1[index]<array2[index])
{
swap(array1[index], array2[index]);
}
May 4 '07 #2
ritvik
8
Thanx alot. i am using rand nad srand
but i canot take this condition. one is the lot size that let us say there are 3 lots
l1 =20 ; l2= 30; l3=15
there can be different orders like
o1 =5 o2 = 10 or=40 o4=5 o5=10
i have to generate the order sizes so that they can be staisfied with the total lot size. they cannot be generated simultaneously the way you said.
thanx once again but can u help in this condition.


You can use combination of srand and rand.

Srand is used to seed the random number generator.

Do both of them simultaneously and make sure Your secod random number is always smaller then first one before adding to repository or database.

int array1[100];
int array2[100];
int index;
srand(...);
....
array1[index] = rand();
array2[index] = rand()
if(array1[index]<array2[index])
{
swap(array1[index], array2[index]);
}
May 4 '07 #3
svlsr2000
181 Expert 100+
What are the different conditions and how los do You have? Can you be more precise in your input?
May 4 '07 #4
ritvik
8
What are the different conditions and how los do You have? Can you be more precise in your input?
i have specified my onlly condiiton. actually i have to generate data for experimentation.
i am required to ask
1)the total number of lots being processed
2) the total number of parallel facilities
3) and the order for each parallel facility from the user.
for e.g user enters 4 lots; 2 parallel facilities and 2 orders for the first facility
3 orders for the second facility.
then i have to generate 4 lot sizes, letus say : 20, 12, 23, 5.
(any value between 2 and 25)
then i hv to generate 5 order sizes(2 for facility 1 and 3 for facility 2)
100,34,23,5,6.
the generation is not fully independent because the total order size should be less tahn or equal to the total lot size so that all orders can be satisfied.
this is the problem.
thanx for your time and effort.
bye
thannx
May 7 '07 #5
ritvik
8
hey what happened all you programmers no solution to this problem
May 9 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jack Smith | last post by:
Help needed on this question. Any help is appreciated. Thanks in advance. Given a binary string (i.e. a finite sequence of 0's and 1's) we choose any two digit substring 01 and replace it by a...
3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
9
by: Jack Addington | last post by:
I have a base form and a base logic class. Each has to know of the other. I'm then inheriting to create descendant form and descendant logic which extend both objects and again have to know of...
7
by: Stephen | last post by:
I have some code which I call from a custom validator however I seem to have got the logic wrong and im having trouble figuring out how to write my code to get things to work the way I require....
11
by: ricolee99 | last post by:
Hi everyone, I'm trying to invoke my .exe application from a remote server. Here is the code: ManagementClass processClass = new ManagementClass ("\\\\" +"RemoteServerName" +...
4
by: John Sitka | last post by:
Hi, sorry for a crosspost but that other news group was showing last post was a week ago so I guess it dosen't see much use... I'm about to start a solution and I'm curious about the approach of...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
5
by: Burt | last post by:
There's an architect at my 200 person company that advocates having many layers in all my C# apps. He wants web services, use case handlers, facade layers, data gateways, etc. When I ask why all...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.