Einzelnen Beitrag anzeigen
Alt 05.05.08, 18:47   #17 (permalink)
FdDi
 
Registriert seit: 10.01.08
FdDi Leistung: Facit NTK
Likes: 0
Standard

Hab das Teil mal in C# geschrieben bin aba noch anfänger mein prog stil ist vllt noch net so toll

Is aba ohne diese Berechnung der versuche und dieser Chance

Code:
using System;

namespace Lottotip
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			ConsoleKeyInfo ci;
			Random r= new Random();
			int[] zahlen = new int[6];
			int tmp,i,zahl,k=0,l=0,ct=0,vs=0,j;
			string eng;
			int[] lotto = new int[50];
			int[] engg = new int[100];
			int[] enggg = new int[6];
			do{
				k=0;l=0;
				for(i=0; i<zahlen.Length;i++){
					tmp = r.Next(1,49)+1;
					if(Array.IndexOf(zahlen, tmp)==-1){
						zahlen[i] = tmp;
					}
				}
				Array.Sort(zahlen);
				Array.Clear(engg,0,engg.Length);
				Array.Clear(lotto,0,lotto.Length);
				for(i = 0;i < zahlen.Length;i++){
					try{	
						Console.Write("Geben sie die "+(i+1)+".te Zahl ein:");
						eng=Console.ReadLine();
						zahl=Convert.ToInt32(eng);
						enggg[i]=zahl;
						if(Array.IndexOf(engg,zahl)!=-1){
							Console.WriteLine("Die Zahl wurde schon eingegeben");
							i--;
						}
						
						if(zahl<=0 || zahl>=50){
							Console.WriteLine("Die zahl muss zwischen 1 und 49 liegen");
							i--;
						}
						foreach(int z1 in zahlen){
							if(z1==zahl)lotto[z1]=enggg[i];
						}
						k++;
						engg[k]=zahl;
					}
					catch(OverflowException){
						Console.WriteLine("Die zahl muss zwischen 1 und 49 liegen");
						i--;
					}
					catch(FormatException){
						Console.WriteLine("Sie Haben keine Zahl Eingegeben");
						i--;
					}
				}
				Array.Sort(enggg);
				Console.WriteLine("Die Lotto zahlen sind");
				foreach(int z in zahlen)Console.Write(z+" ");
				Console.WriteLine("\nDeine Eingabe War");				
				for(i=0;i<enggg.Length; i++){
					Console.Write(enggg[i]+" ");
				}
				Array.Clear(engg,0,engg.Length);
				foreach(int z in enggg){
					if(Array.IndexOf(lotto,z)!=-1){
						engg[l]=z;
						l++;
					}
				}
				Console.WriteLine("\nSie Haben "+l+" Übereinstimmungen");
				for(i=0; i< l;i++){
					Console.Write("Zahl "+(i+1)+": "+engg[i]+" ");
				}
				Console.WriteLine("\nWollen sie es noch einmal versuchen ?<j>");
				ci=Console.ReadKey(true);
			}while(Char.ToUpper(ci.KeyChar)=='J');
				
		}
	}
}
FdDi ist offline   Mit Zitat antworten
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61