VLS Roulette Forum

Roulette System Development & Testing => Roulette Coding Zone => Topic started by: Tole on February 15, 2009, 05:02:13 PM

Title: roulette and c++
Post by: Tole on February 15, 2009, 05:02:13 PM
i have little program in devc++ that counts how many times some of dozens didn't come but doesn't work well becouse of zero....i dont know how to include zero in all calculations....and this program takes rand numbers from rand function which isnt good for testing....it could be changed that i can put rand number from rand.org for example ....i hope you understend what i mean :)

here is program

#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int getSubArrSize(char niz1[], int i, int j); // vraca velicinu podniza
int main ()
{
&nbsp; &nbsp; int i,j,m;
&nbsp; &nbsp; int result = 1;
&nbsp; &nbsp; int index = -1;
&nbsp; &nbsp;
&nbsp; &nbsp; srand ( time(NULL) ); //podesavanje seed-a kod rand() funkcije
&nbsp; int niz[50];
&nbsp; char nizSlova[50];
&nbsp; for( i=0;i<50;i++)
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;niz = rand()%36+1;&nbsp; &nbsp; &nbsp;//pozivanje rand() funkcije ide modul 36 + 1 da bi nam rezultat bio u opsegu od 0 - 36
&nbsp; }
&nbsp; for( i=0;i<50;i++)
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;printf(" %d ", niz);&nbsp; &nbsp;// stampanje niza brojeva
&nbsp; }
printf("\n");

// pretvaranje niza brojeva u niz slova u zavisnosti od uslova
&nbsp; for( i=0;i<50;i++)
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;if (niz<=12 && niz>0 )
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nizSlova = 'M';
&nbsp; &nbsp; &nbsp; &nbsp;else if (niz>12 && niz<=24)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nizSlova = 'L';
&nbsp; &nbsp; &nbsp; &nbsp;else if (niz>24 && niz<=36)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nizSlova = 'H';
&nbsp; &nbsp; &nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nizSlova = '0';
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; }

&nbsp; &nbsp; for( i=0;i<50;i++)
&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;printf(" %c ", nizSlova);&nbsp; // stampanje niza karaktera
&nbsp; }
printf("\n");

// nalazenje podniza&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( I = 0 , j=1 ; j< 50; i++ ,j++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( nizSlova == nizSlova[j])
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int subArrSize = getSubArrSize(nizSlova, i, j);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(result < subArrSize)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = subArrSize;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = i;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
printf("Najduzi podniz pocinje na poziciji %d i dugacak je %d karaktera \n", index, result);
&nbsp; puts ("Eto ga! ");
&nbsp; scanf("%d",&m);
&nbsp; return 0;
}

// funkcija koja vraca duzinu najduzeg podniza
int getSubArrSize(char niz1[], int i, int j)
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int size = 1;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (I < j)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(niz1 == niz1[j])
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { size++;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;j++;}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return size;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return size;
&nbsp; &nbsp; &nbsp; &nbsp; }


if someone know to do in devc++ can change it and it can help to test spins with RNG....also can wrote other programs similar to this to test another sistems.....it's more easy to test whit program

for example on this system nolinks://vlsroulette.com/vls'-notes/curious-'follow-the-stream'-version/ (nolinks://vlsroulette.com/vls'-notes/curious-'follow-the-stream'-version/) program to calculate how many times same numer come in row and distance betwen that and other number that come in row....example...15,25,35,35,1,24,17,28,13,23,23...so we have 35 and 23 and distance is 5...its to test does it work or how many units it need....its could be small program but efective for testing....

anyone?
Title: Re: roulette and c++
Post by: Tole on February 18, 2009, 05:27:03 AM
???????????????????????????
Title: Re: roulette and c++
Post by: VLSroulette on February 18, 2009, 03:49:03 PM
Hey Tole,

I'm not a C++ programmer, but I can tell you brainstorming isn't quite the section for code! ;)

I hope you'll be okay with me moving it to coding section?  :thumbsup:
Title: Re: roulette and c++
Post by: Tole on February 19, 2009, 08:40:46 AM
ok