Help in generating the same random numbers each time of the program executi

dear friends
i am facing a problem that the random numbers generated at time of each exectuion of the program are not the same, i want to generate the same random numbers every time time i run the program. i need your help. i am giving the code in c++ if anybody can help in providing the solution so that i get the same random numbers at every run of the program. waiting for your help
wit regards
jaya shankar
#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
class density
int s[150][150],parent[150][150],i,j,l,n,loop;
public:
void bd(void);
void css(void);
void density :: bd(void)
cout<<"ENTER THE POPULATION SIZE = ";
cin>>n;
cout<<"\nENTER THE NO.OF LOOPS = ";
cin>>loop;
for(i=0;i<n;i++)
for(j=0;j<80;j++)
s[i][j]=rand()%2;
cout<<"s:"<<s[i][j];
void density :: css(void)
int a,b;
float c;
for(i=0;i<n;i=i+2)
     b=rand()%100;
     cout<<"random b="<<b;
main()
density d;
d.bd();
d.css();

To generate the same random,it's impossible!
why do you want to do that?

Similar Messages

  • Have restarted my computer multiple times, because of ios5 and it is still freezing at the same loading spot each time of the download. this is my 10th time attempting at updating the software

    i have plugged in my phone attempting at the new ios5 download multiple times and to begin with it claims to me that it cannot restore my ipod but gives no reason. but i continues with the download, and now i have a blank iphone with no data on it at all, says to plug it into itunes, so i do and it freezes in the same spot about a tenth of the way full of the bar below the apple logo.

        roadpup27, having multiple replacement devices is no fun! I'm sorry you have to endure this experience with your phone. I would like to help with your issue and ensure you that we do not anticipate our certified like new phones having issues. They go through a 100-point check and in most cases work just as well or better than a new phone because they have updated software. I hope your replacement phone works for you so that you do not miss any events or be delayed. Although we can not compensate you for your phone issues, we will continue to replace your phone until you have a working device if the phone is under warranty. Please keep us posted.
    KinquanaH_VZW

  • Help in generating the same random numbers at every time of executuion

    dear friends
    i am facing a problem that the random numbers generated at time of each exectuion of the program are not the same, i want to generate the same random numbers every time time i run the program. i need your help. i am giving the code in c++ if anybody can help in providing the solution so that i get the same random numbers at every run of the program. waiting for your help
    wit regards
    jaya shankar
    #include<iostream.h>
    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    #include<math.h>
    class density
    int s[150][150],parent[150][150],i,j,l,n,loop;
    public:
    void bd(void);
    void css(void);
    void density :: bd(void)
    cout<<"ENTER THE POPULATION SIZE = ";
    cin>>n;
    cout<<"\nENTER THE NO.OF LOOPS = ";
    cin>>loop;
    for(i=0;i<n;i++)
    for(j=0;j<80;j++)
    s[j]=rand()%2;
    cout<<"s:"<<s[j];
    void density :: css(void)
    int a,b;
    float c;
    for(i=0;i<n;i=i+2)
    b=rand()%100;
    cout<<"random b="<<b;
    main()
    density d;
    d.bd();
    d.css();

    You have to read the documentation for the java.util.Random class.
    "If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers. In order to guarantee this property, particular algorithms are specified for the class Random"
    Here is a peace of code that will do wat you need:
    Random rand = new Random(100);
    for(int i=0; i<10; i++)
         System.out.println("Random="+ rand.nextInt(10));

  • How can I have use the same div ID multiple times on the same page?

    Okay so a problem I encounter a lot is that often times I want to use the same div ID several times on the same page. An example of this is when I'm creating table like designs.
    Let's say for instance I create a div ID called 'product-container'. I want to use 'product-container' multiple times on the same page but if I do this it is improper XHTML and will throw errors in any XHTML validator (you are only allowed to use a div ID once on any XHTML page in order for it to be standards compliant).
    Now the first option is that I could define 'product-container' in my CSS style sheet multiple times by doing something like this...
    #product-container {
         width: 300px;
    #product-container-2 {
         width: 300px;
    #product-container-3 {
         width: 300px;
    #product-container-4 {
         width: 300px;
    What you will see there however is that it seems pointless to define the same ID numerous times over (just adding a number on the end) when each ID is the exact same thing and has the exact same attributes.
    Now what I have noticed is that there are some sites out there who manage to have the same ID appear several times in the code but add a number to it just like above. The difference is that they only have one definition for 'product-cointainer' in their CSS document but in their actual XHTML code they have IDs for 'product-container' but with numbers on the end like 2,3,4,5, etc. It's almost as if JavaScript or some other code is automatically appending a number on the end of the ID so the validator won't consider the markup to be invalid, but yet it knows that it's using the same 'product-container' style that is contained in the CSS style sheet.
    I hope I explained this correctly. I'm just hoping to find a way that I can put the same div ID on a page multiple times without having to define it over and over again in my CSS.
    Any help is much appreciated!

    Because it seems like by using a class you can't make this position as 
    well as you can by using an ID. Am I wrong?
    An ID name can be used only one time per page.  A class name can be used multiple times per page.
    .product {
    width: 300px;
    text-align:left;
    color: #FF0000
    border: 2px solid #666;
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • I'm trying to install the new version, but each time during the installation, "Error writing to file: C:/Program Files (x86)/Common Files/Apple/Mobile Device/Support/AppleMobileDeviceHelper.resources/Info.plist." Keeps popping up. What am I doing wrong?

    I'm trying to install the new version, but each time during the installation, "Error writing to file: C:/Program Files (x86)/Common Files/Apple/Mobile Device/Support/AppleMobileDeviceHelper.resources/Info.plist." Keeps popping up. What am I doing wrong?

    That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
    Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
    Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
    Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards?

  • TS2755 keep receiving the same text message multiple times, at the same time of the night. How can I stop this?Thabnks

    Hi
    I keep on receiving the same text message multiple times and at around the same time each night. Any idea how I can stop this happening? The text messages are originating from to separate Saudi Arabian mobile numbers. Both these people are listed in my contacts so do you think if I delete their names it might stop the texts coming htrough each night?
    Cheers

    Deleting the people from your contacts will not stop the messages. Have you tried talking to the people and finding out if they're sending you messages? You could try contacting your carrier and finding out what blocking services they offer. However, theat would block all messages from those people.

  • Can any one help.  I have put music on my phone and its showing lots of the same covers for each song on the album, how do i make it into one album?

    Hi Can anyone help? I have put music on my i-phone but its showing lots of the same album cover for each individual song, how can I create one cover for the album?

    Do you have Sidebar ON?
    iTunes > View > Show Sidebar.
    Connect and select iPhone in iTunes Sidebar under DEVICES, choose the Music tab on the right, select Sync Music and whatever music you the on iPhone. Click Apply (bottom right)

  • On my 5th replacement phone for the same exact problem each time

    I would just like to first of all say that I am the least bit satisfied with Verizon Wireless. I know that this is not the scenario for every customer, but you guys have literally made having a cell phone really really difficult and really really depressing due to being phoneless constantly, awaiting for the next replacement.
    I've had 4 replacement Incredible 2's, and I am currently awaiting my 5th replacement.
    Each time I get one of these phones, the charge port stops working after a months use. The first couple of times I assumed it was my own fault that the charge port stopped working, now I am considering differently. For the past 2 replacements, I have gotten rid of my car charger and only charged my phone on my nightstand at night to ensure that I was not wiggling the charge port around. DESPITE this, the charger port STILL stopped working, and I am now phone less for the 5th time. And I've had 3 of these replacements in 3-4 months.
    There have been 5 different occasions where I have had to inconveniently  rearrange my plans for the next few days according to the fact of me not having a phone because the phones you send me don't last more than a months time.
    This time, I am having to put back a vacation that I was expecting to leave for tomorrow morning. My phone stopped charging last night, and I am now phoneless for the weekend until Verizon Wireless can ship me another phone Monday.
    I should not have to deal with this kind of inconvenience if I am going to choose you as my wireless provider.
    Especially not 5 different times for all the same reason when you as a company could of fixed this problem long ago by sending me a better phone. Verizon Wireless should honor their loyal paying customers. The only thing Verizon Wireless is doing for me right now is making my life difficult.
    I want some sort of compensation or a resolve to this situation. I am beyond dissatisfied.

        roadpup27, having multiple replacement devices is no fun! I'm sorry you have to endure this experience with your phone. I would like to help with your issue and ensure you that we do not anticipate our certified like new phones having issues. They go through a 100-point check and in most cases work just as well or better than a new phone because they have updated software. I hope your replacement phone works for you so that you do not miss any events or be delayed. Although we can not compensate you for your phone issues, we will continue to replace your phone until you have a working device if the phone is under warranty. Please keep us posted.
    KinquanaH_VZW

  • IPhoto keeps trying to import the same 42 files each time

    I imported thousands of pictures from a formerly Windows based backup external hard drive. Everything went well except with 42 pictures. Every time I bring up iPhoto, it tells me that these 42 pictures were not imported and then it ask me if I wish to import them. I click yes and it attempts and then says it was unable to import them and has now placed in them a recovered folder in the pictures folder under finder. That would be okay except that it does it every time. I just removed 14 folders of the same files. If I click No it creates a recovered folder within the iPhoto album section, How do I stop this from happening? I just got off the phone with Apple Care and they were no help. All he told me to do was rebuild iPhoto database. We are talking about 15,000 pictures here that have been put in specific folders and certain albums. I do not want to go through that process again. Oh, I am doing this on a new iMac I just purchased. Any suggestions?

    this is one of the very few times when the answer is to delete something form your iPhoto library
    Quit iPhoto and right click (control click) on the iPhoto library and choose the show package contents option - look in the iPhoto library for a folder named import (or importing) and drag it to the desktop - do not move or change anything else - launch iPhoto and everything will be ok
    Open the import(ing) folder on your desktop and if there are any photos you want import them into iPhoto - and then drag the import(ing) folder to the trash and empty it
    LN

  • Every time I click the Firefox icon a panel says it is already in use and to clear it I need to re-boot, after re-booting the same message appears each time

    I cannot get into Mozilla as the panel appears each time to say it is running

    Must be the "hang at exit" problem. <br /><br />
    #Stop the Firefox process:
    #*[http://kb.mozillazine.org/Kill_application Mozillazine - Kill application]
    #*Windows 7 users click [http://www.techrepublic.com/blog/window-on-windows/reap-the-benefits-of-windows-7s-task-manager/2576 here]
    #Why Firefox may hang:
    #*[http://support.mozilla.com/en-US/kb/Firefox+hangs Firefox hangs] (see Hang at exit)
    #*[http://kb.mozillazine.org/Firefox_hangs Firefox hangs (Mozillazine)] (see Hang at exit and Closing Firefox properly)
    #*[https://support.mozilla.com/en-US/kb/Firefox+is+already+running+but+is+not+responding Firefox is already running but is not responding]
    #Use Firefox Safe Mode to find a problem with an Extension or Plugin:
    #*Don't check anything when entering Safe Mode, just continue
    #*If the problem does not occur in Safe Mode it is probably and Extension or Plugin causing the problem
    #*See:
    #**[[Safe Mode]] and [http://kb.mozillazine.org/Safe_Mode Safe Mode (Mozillazine)]
    #**[http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes Troubleshooting extensions and themes]
    #**[http://support.mozilla.com/en-US/kb/Troubleshooting+plugins Troubleshooting plugins]
    #**[http://support.mozilla.com/en-US/kb/Basic+Troubleshooting Basic Troubleshooting]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • Reusing the same jsp include multiple times on the same page

    If someone knows a way out of this
    I'd like to print out 2 records of the same data type I have a JSP include which does that.
    Now my issue is how to use the same include twice on the same page
    Ideally I would like to do the following:
    <%
    request.setAttribute("person", person1);
    %>
    <jsp:include page="./person.jsp"/>
    <%
    request.setAttribute("person", person2);
    %>
    <jsp:include page="./person.jsp"/>
    And in person.jsp
    I could have
    <h:inputText name=#{person.name}/>
    This fails in the updateModel phase - And I realize why it's failing. There really is no person managed bean.
    It's just that I am at a kind of loss as to what I need to do now -
    Am missing something or is it just impossible to use jsp:includes the way Ive tried to?

    I do not understand, have you created a backing bean named person? Have you defined it in your config file?
    Please copy/paster your backing bean code and config file.
    Normally, you can set directly the value of the bean by using some java code in your jsp instead of setting the request attribute.

  • Does the iPhone have a sleep timer like the iPod touch?

    Just want to know if the iphone has the same kind of sleep timer as the ipod touch. Will be getting the iphone as soon as I can upgrade and need the sleep timer. I use it all the time on the ipod touch.
    thanks

    Yes...iPhone Clock App>Timer.

  • Have the developers considered randomizing the numbers for the passcode?  It is easy to watch the pattern when someone enters their passcode.  However, if the numbers appeared is a random order each time, it would enhance the security feature even more.

    Have the developers considered randomizing the numbers for the passcode?  It is easy to watch the pattern when someone enters their passcode.  However, if the numbers appeared is a random order each time, it would enhance the security feature even more.  Personally, I would prefer this option with security in mind.

    He slightly beat you Meg, and I'm in the same boat with you. If I used a passcode I believe I would go with the feature to use a longer alphanumeric passcode rather than a 4 digit number even with the random code entry.
    And of course if Apple did put this feature in they need to make it an option or we'll see lots of posts wanting to know how to get rid of it.

  • Hi, I have an iPhone 4 which rings people when it is locked, whether or not in my pocket.  I always lock it when not using it.  Can anyone help? It is calling random numbers, not the last person or anyone even recently called on my recents list. Thanks

    Hi, I have an iPhone 4 which rings people when it is locked, whether or not in my pocket.  I always lock it when not using it.  Can anyone help? It is calling random numbers, not the last person or anyone even recently called on my recents list. Thanks

    Pay no attention to iinami, the amount of replies to people saying their handsets must have been jailbroken everytime iTunes throws out an error is tremendous. (Clearly you don't need to have any real knowledge to get to level 3 on these forums, let's hope apple's geniuses know a lot more than some of their customers.)
    http://support.apple.com/kb/TS3694
    Solution below.
    Error 9
    This error occurs when the device unexpectedly loses its USB connection with iTunes. This can occur if the device is manually disconnected during the restore process. This issue can be resolved by performing USB troubleshooting, using a different USB dock-connector cable, trying another USB port, restoring on another computer, or by eliminating conflicts from third-party security software.

  • I cannot open iCal because of a problem. Can anybody help me? The computer will not allow it to open and sends a message to apple each time. The icon has gone from the dock, but ical works on my iPad and I am afraid to sync it with my computer.?

    I cannot open iCal because of a problem. Can anybody help me? The computer will not allow it to open and sends a message to apple each time. The icon has gone from the dock, but ical works on my iPad and I am afraid to sync it with my computer in case it wipes everything .

    I have the exact same problem. I have not changed anything. This is probably a bug or something that has gone bad with Mac OS X (10.7.2). I have not found any solution for this on the web.
    MacBook Pro, Mac OS X (10.7.2).

Maybe you are looking for

  • Ovi Store - Major major Rant to Nokia - you may wa...

    Another classic fail on Nokia's part! Nokia has announced closure dates for Mosh and Widsets through e-mails and news releases along with the eventual replacement of these services by the new Ovi Store. However, the smarts at Nokia have not included

  • Why doesn't my alt key work?

    In my Photoshop CC, the alt key only duplicates the layer; I can't use the clone tool or the healing brush.  Does anyone know what is going on here?

  • Are the ANY Apple Customer Service people here??????

    If not, then why are these forums listed under "Support"??? If there are, then why don't they answer questions to REAL problems people are having instead of answering questions like, "How do I turn my iPad off?"???

  • Synchronisation between asset and equipment

    Hi, team ,please guide me how can i genera te same no for equipment when asset is synchronised with equipment. Because asset class is linked with equipment category not with object type. Thanx in advance.

  • Missing print options

    It makes no sense, please help! I have a Pixma MG8220. I have no way to print two sided documents or print in black and white B&W when connected via USB. These options ARE available if I connect via wireless. Worse yet, PDF documents won't offer thes