Loop this...

This is a discussion on Loop this... within the C++ Programming forums, part of the General Programming Boards category; How would I loop 1's and 0's into "0001010100111010010" or something similar to make it look like it does in ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    12

    Loop this...

    How would I loop 1's and 0's into "0001010100111010010"
    or something similar to make it look like it does in the matrix, is it possible?

    And if so how would you stop the loop?

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Try this
    Code:
    #include <iostream.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    
    int main()
    {
    	srand(time(NULL));
    
    	for(int i = 0; i < 100000000; i++)
    	{
    		cout << 1 - rand()%-2;
    		i++;
    	}
    
    	cout << "\n";
    	return 0;
    }

  3. #3
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680

    Re: Loop this...

    Or this:
    Code:
    #include <iostream.h>
    #include <stdlib.h>
    #include <time.h>
    
    int main(void)
    {
        char s[] = "01 ";
        srand((unsigned int)time(NULL));
        while(1) cout << s[rand()%3];
        return 0;
    }
    You can only stop the loop if you're THE ONE

  4. #4
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    I think I like mine better

  5. #5
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Well...mine looks more like the matrix (seen it 2 days ago).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. nested loop, simple but i'm missing it
    By big_brother in forum C Programming
    Replies: 19
    Last Post: 10-23-2006, 10:21 PM
  2. While loop misbehaving (or misunderstanding)
    By mattAU in forum C Programming
    Replies: 2
    Last Post: 08-28-2006, 02:14 AM
  3. loop in a linked linked lists
    By kris.c in forum C Programming
    Replies: 6
    Last Post: 08-26-2006, 12:38 PM
  4. while loop help
    By bliznags in forum C Programming
    Replies: 5
    Last Post: 03-19-2005, 11:30 PM
  5. loop issues
    By kristy in forum C Programming
    Replies: 3
    Last Post: 03-05-2005, 08:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21