Главная » Статьи » Статьи

Randomize Function

  

#include "stdafx.h"
#include <STDLIB.H>

int Randomize(int nMax, bool range);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     
int       nCmdShow)
{
    // TODO: Place code here.
    char szText[MAX_PATH];

    wsprintf(szText,"%d",Randomize(16,TRUE));
    MessageBox(NULL,szText,"Randomize",MB_OK);

    return 0;
}

int Randomize(int nMax, bool range)
{
    srand(GetTickCount()); int random_integer = (rand()%nMax);
    if(range){random_integer++; return random_integer;}

    return random_integer;
}

 

#include "stdafx.h"
#include <STDLIB.H>

int Randomize(int nMax, bool range);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     
int       nCmdShow)
{
    // TODO: Place code here.
    char szText[16][MAX_PATH] =
    {
        "Randomize = 0",
        "Randomize = 1",
        "Randomize = 2",
        "Randomize = 3",
        "Randomize = 4",
        "Randomize = 5",
        "Randomize = 6",
        "Randomize = 7",
        "Randomize = 8",
        "Randomize = 9",
        "Randomize = 10",
        "Randomize = 11",
        "Randomize = 12",
        "Randomize = 13",
        "Randomize = 14",
        "Randomize = 15",
    };

    MessageBox(NULL,szText[Randomize(16,FALSE)],
    "Randomize",MB_OK);

    return 0;
}

int Randomize(int nMax, bool range)
{
    srand(GetTickCount()); int random_integer = (rand()%nMax);
    if(range){random_integer++; return random_integer;}

    return random_integer;
}

 

Добавлено: (28.03.2009) 
Просмотров: 1124 | Теги: randomize, CPP, Function | Рейтинг: 0.0/0

Меню сайта



Категории раздела

Поиск

Друзья сайта

Параметры

 
 

Статистика

TOPlist TOPlist
Copyright 2009 | Каталог   Хостинг от uCoz |

Free counters