mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
96 lines
2.7 KiB
C++
96 lines
2.7 KiB
C++
/* This file is part of the KDE libraries
|
|
Copyright (c) 1999 Waldo Bastian <bastian@kde.org>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License version 2 as published by the Free Software Foundation.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include <QtCore/QList>
|
|
#include <QtCore/QString>
|
|
|
|
#include "krandomsequence.h"
|
|
#include "krandom.h"
|
|
#include "kcmdlineargs.h"
|
|
#include "kaboutdata.h"
|
|
//#include "kapplication.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
int
|
|
main( /*int argc, char *argv[]*/ )
|
|
{
|
|
//KAboutData about("krandomsequencetest", 0, ki18n("krandomsequencetest"), "version");
|
|
//KCmdLineArgs::init(argc, argv, &about);
|
|
//KApplication a;
|
|
|
|
long seed;
|
|
KRandomSequence seq;
|
|
|
|
seed = 2;
|
|
seq.setSeed(seed);printf("Seed = %4ld :", seed);
|
|
for(int i = 0; i < 20; i++)
|
|
printf("%3ld ", seq.getLong(100));
|
|
printf("\n");
|
|
|
|
seed = 0;
|
|
seq.setSeed(seed);printf("Seed = %4ld :", seed);
|
|
for(int i = 0; i < 20; i++)
|
|
printf("%3ld ", seq.getLong(100));
|
|
printf("\n");
|
|
|
|
seed = 0;
|
|
seq.setSeed(seed);printf("Seed = %4ld :", seed);
|
|
for(int i = 0; i < 20; i++)
|
|
printf("%3ld ", seq.getLong(100));
|
|
printf("\n");
|
|
|
|
seed = 2;
|
|
seq.setSeed(seed);printf("Seed = %4ld :", seed);
|
|
for(int i = 0; i < 20; i++)
|
|
printf("%3ld ", seq.getLong(100));
|
|
printf("\n");
|
|
|
|
seq.setSeed(KRandom::random());
|
|
|
|
QList<QString> list;
|
|
list.append(QString("A"));
|
|
list.append(QString("B"));
|
|
list.append(QString("C"));
|
|
list.append(QString("D"));
|
|
list.append(QString("E"));
|
|
list.append(QString("F"));
|
|
list.append(QString("G"));
|
|
|
|
for(QList<QString>::Iterator str = list.begin(); str != list.end(); ++str)
|
|
printf("%s", str->toLatin1().data());
|
|
printf("\n");
|
|
|
|
seq.randomize(list);
|
|
|
|
for(QList<QString>::Iterator str = list.begin(); str != list.end(); ++str)
|
|
printf("%s", str->toLatin1().data());
|
|
printf("\n");
|
|
|
|
seq.randomize(list);
|
|
|
|
for(QList<QString>::Iterator str = list.begin(); str != list.end(); ++str)
|
|
printf("%s", str->toLatin1().data());
|
|
printf("\n");
|
|
|
|
seq.randomize(list);
|
|
|
|
for(QList<QString>::Iterator str = list.begin(); str != list.end(); ++str)
|
|
printf("%s", str->toLatin1().data());
|
|
printf("\n");
|
|
}
|