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 ()
{
int i,j,m;
int result = 1;
int index = -1;
srand ( time(NULL) ); //podesavanje seed-a kod rand() funkcije
int niz[50];
char nizSlova[50];
for( i=0;i<50;i++)
{
niz = rand()%36+1; //pozivanje rand() funkcije ide modul 36 + 1 da bi nam rezultat bio u opsegu od 0 - 36
}
for( i=0;i<50;i++)
{
printf(" %d ", niz); // stampanje niza brojeva
}
printf("\n");
// pretvaranje niza brojeva u niz slova u zavisnosti od uslova
for( i=0;i<50;i++)
{
if (niz<=12 && niz>0 )
nizSlova = 'M';
else if (niz>12 && niz<=24)
nizSlova = 'L';
else if (niz>24 && niz<=36)
nizSlova = 'H';
else
nizSlova = '0';
}
for( i=0;i<50;i++)
{
printf(" %c ", nizSlova); // stampanje niza karaktera
}
printf("\n");
// nalazenje podniza
for( I = 0 , j=1 ; j< 50; i++ ,j++)
{
if( nizSlova == nizSlova[j])
{
int subArrSize = getSubArrSize(nizSlova, i, j);
if(result < subArrSize)
{
result = subArrSize;
index = i;
}
}
}
printf("Najduzi podniz pocinje na poziciji %d i dugacak je %d karaktera \n", index, result);
puts ("Eto ga! ");
scanf("%d",&m);
return 0;
}
// funkcija koja vraca duzinu najduzeg podniza
int getSubArrSize(char niz1[], int i, int j)
{
int size = 1;
while (I < j)
{
if(niz1 == niz1[j])
{ size++;
j++;}
else
return size;
i++;
}
return size;
}
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?
???????????????????????????
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:
ok