Hallo,
das wird nicht ganz so einfach.
- Muessen es vordefinierte NAMEN sein?
Es gibt die Moeglichkeit Zufallsziffern (auch aus eingegrenztem Pool) auszugeben. Stichwort: $Random
Das ganze gibts auch online unter: http://www.random.org/
hth,
ntmazda
Ergebnis 1 bis 8 von 8
- 23.12.2010, 20:32 #1
Zufallsname
Hallo
ich hab mal eine Frage:
Ich habe 10 namen und würde sie gerne zufällig ausgespuckt bekommen .
Also das ich zum beispiel :
A
B
C
D
E
F
G
H
I
J
und ich gebe was ein und es kommt C dann nochmal und es kommt J
geht das irgendwie am besten direkt im terminal
Gruß MaxJa, ich besitze auch diverse Produkte von Apple
Und auch ein iPad 2
- 25.12.2010, 12:10 #2
- 25.12.2010, 12:22 #3
ja am besten
Ja, ich besitze auch diverse Produkte von Apple
Und auch ein iPad 2
- 25.12.2010, 14:52 #4
Du kannst dir z.B. ein kleines C++ Programm schreiben, das das macht.
Ich versuche mich mal an einem Beispiel: random.cpp
Das berechnet eine Zufallszahl zwischen 1 und der Anzahl der Namen und gibt den Namen an dieser Position aus.Code:#include <iostream> #include <time.h> using namespace std; int main(int argc, char **argv){ if(argc > 1){ time_t t; time(&t); srand((unsigned int)t); int index = 1 + rand() % (argc - 1); cout << argv[index] << endl; } else{ cout << "usage: ./random NAME1 NAME2 ..." << endl; } return 0; }
Übersetzen mit: (Developer Tools sind erforderlich)
Aufrufen mit:Code:g++ random.cpp -o random
Code:./random HEINZ DIETER KURT KLAUS ANDREAS STEFFEN
Geändert von Guy.brush (25.12.2010 um 16:15 Uhr) Grund: Verbesserung
It's more fun to be a pirate than to join the navy.RTF Apfeltalk Wiki
- 25.12.2010, 14:55 #5
gut Developer Tools habe ich
nit welchem von den Tools soll ich das den öffnenJa, ich besitze auch diverse Produkte von Apple
Und auch ein iPad 2
- 25.12.2010, 16:05 #6
Erstellen kannst du das mit irgendeinem Editor, z.B. Fraise, TextWrangler, TextMate, notfalls auch TextEdit oder Xcode. Übersetzen und aufrufen dann mit dem Terminal.
It's more fun to be a pirate than to join the navy.RTF Apfeltalk Wiki
- 25.12.2010, 18:25 #7
Erstell dir das script random.sh
Script random.sh ausfuehrbar machen:
Zitat von random.sh
chmod a+x random.sh
Aufruf:
./random.sh HEINZ DIETER KURT KLAUS ANDREAS STEFFEN52 2E 54 2E 46 2E 4D 21 0A 44 65 6E 6E 1F 73 69 65 1F 77 69 73 73 65 6E 1F 6E 69 63 68 74 2C 1F 77 61 73 1F 73 69 65 1F 74 75 6E 21
Make it idiot-proof, and they'll make a better idiot.
- 28.12.2010, 12:39 #8
danke klappt
Ja, ich besitze auch diverse Produkte von Apple
Und auch ein iPad 2




Zitieren
