Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream Zahlen;
int Zufall;
Zahlen.open("E:\\Programmieren\\Programmiertes\\C++\\Zufällige Zahlenreihenfolge\\Zahlen.txt");
srand(time(NULL));
for( int y = 0; y <= 10000; y++) {
Zufall = (rand() % 10000) ;
if( Zufall <= 999 && Zufall >= 100)
Zahlen <<"0";
else if( Zufall <= 99 && Zufall >= 10)
Zahlen <<"00";
else if( Zufall < 10 )
Zahlen <<"000";
Zahlen << Zufall << endl;
}
Zahlen.close();
int Ende;
cin >> Ende;
return 0;
}
public class RandomNums {
public static void main(String[] args) throws IOException {
ArrayList<String> nums = new ArrayList<String>();
for(int i=0; i<1000; i++)
nums.add(String.format("%04d", i));
Collections.shuffle(nums);
FileWriter writer = new FileWriter(new File("nums.txt"));
for(String num : nums) {
writer.write(num +"\n");
writer.flush();
}
}
}
import random
def add_num():
x = random.randrange(0,10000,1)
if x in zahlen:
return add_num()
else:
return x
zahlen = [-1] * 10000
output = open("ausgabe.txt","w")
for i in zahlen:
i= add_num()
output.write(str(i)+"\n")
output.close()
#include "stdafx.h"
using namespace System;
using namespace System::IO;
int main(array<System::String ^> ^args)
{
Int32 zahl[10000];
Boolean gezogen[10000];
Random ^zufall = gcnew Random();
for (Int32 zaehler=0;zaehler<=9999;zaehler++)
{
gezogen[zaehler]=false;
}
for (Int32 zaehler=0;zaehler<=9999;zaehler++)
{
zahl[zaehler]=zufall->Next(0,10000);
while (gezogen[zahl[zaehler]]==true)
{
zahl[zaehler]=zufall->Next(1,10000);
}
gezogen[zahl[zaehler]]=true;
}
StreamWriter ^datei = gcnew StreamWriter("0000-9999.txt");
for (Int32 zaehler=0;zaehler<=9999;zaehler++)
datei->WriteLine("{0}",zahl[zaehler]);
datei->Close();
return 0;
}
#include <stdlib.h>
#include <stdio.h>
main()
{
srand(time(0));
int a[9999],i,c,k;
FILE *file;
for(i=0;i<=9999;i++)a[i]=i;
for(i=0;i<=9999;i++){c=a[i];a[i]=a[k=rand()%10000];a[k]=c;}
file=fopen("random_number_list.txt", "w");
if(file==NULL){printf("File Access Error");exit(EXIT_FAILURE);}
for(i=0;i<=9999;i++)fprintf(file, "%00004d\n",a[i]);
fclose(file);
}
a = []; i = 0; k = 0
while a.length != 10000
b = rand(10000); k = 0
a.each { |part|
if part == b
k = 1
end
}
if k != 1
a.push(b)
if b < 10
puts "000#{b}"; c = "000#{b}"
elsif b < 100
puts "00#{b}"; c = "00#{b}"
elsif b < 1000
puts "0#{b}"; c = "0#{b}"
else
puts "#{b}"; c = "#{b}"
end
file = File.new("zahlen.txt", "a"); file.puts c; file.close
end
end
Module Module1
Public ausgegeben(9999) As Integer
Public zahl As Integer
Public fName As String = "C:\Zahlenspiel.txt"
Public alt As String
Public neu As Boolean = False
Sub Main()
For y As Integer = 0 To 9999
ausgegeben(y) = -1
Next
Console.WriteLine("Working...")
For x As Integer = 0 To 9999
Randomize()
neu = False
Do
zahl = CInt(Int((10000 * Rnd()) + 1))
zahl -= 1
If Array.IndexOf(ausgegeben, zahl) = -1 Then
Try
Dim inStream As IO.StreamReader
inStream = New IO.StreamReader(fName)
alt = inStream.ReadToEnd
inStream.Close()
inStream = Nothing
Catch
alt = ""
End Try
Dim outStream As IO.StreamWriter
outStream = New IO.StreamWriter(fName)
outStream.Write(Format(zahl, "0000") & vbCrLf & alt)
outStream.Close()
outStream = Nothing
ausgegeben(x) = zahl
neu = True
End If
Loop While neu = False
Next
Console.WriteLine("Done!")
Console.ReadLine()
End Sub
End Module
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableArray *numbers = [NSMutableArray arrayWithCapacity:10000];
int i;
srand(time(NULL));
for (i = 0; i < 10000; i++) {
NSString *content = [NSString stringWithFormat:@"%.4d", i];
NSUInteger numbersCount = [numbers count];
NSUInteger randomIndex = rand() % (numbersCount+1);
[numbers insertObject:content atIndex:randomIndex];
}
[[numbers componentsJoinedByString:@"\n"] writeToFile:@"output.txt" atomically:YES encoding:NSUTF8StringEncoding error:NULL];
[pool drain];
return 0;
}
[delphi]
procedure BlubGod(Filename: String; Max: DWord);
var
StrLst : TStringList;
Values : Array of DWord;
i : Integer;
begin
StrLst := TStringList.Create;
try
Randomize;
SetLength( Values, Max );
for i := 0 to Max - 1 do
Values[i] := i;
StrLst.BeginUpdate();
try
repeat
i := Random( Max );
dec( Max );
StrLst.Add( IntToStr( Values[i] ) );
if i = Max then
Continue;
// some exchange magic...
Values[i] := Values[i] - Values[Max];
Values[Max] := Values[Max] + Values[i];
Values[i] := Values[Max] - Values[i];
until Max = 0;
finally
StrLst.EndUpdate();
end;
StrLst.SaveToFile( Filename );
finally
StrLst.Free;
end;
end;
[/delphi]
BlubGod('blub.txt', 1000000);