<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Programming Archive - Pixelfriedhof</title>
	<atom:link href="https://pixelfriedhof.com/en/category/other-topics-thought-tray/programming/feed/" rel="self" type="application/rss+xml" />
	<link>https://pixelfriedhof.com/en/category/other-topics-thought-tray/programming/</link>
	<description>IT-Blog, Fotoblog, Travelblog, Nerdstuff</description>
	<lastBuildDate>Tue, 04 Feb 2020 12:52:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://pixelfriedhof.com/wp-content/uploads/2022/02/cropped-My-project-3-32x32.png</url>
	<title>Programming Archive - Pixelfriedhof</title>
	<link>https://pixelfriedhof.com/en/category/other-topics-thought-tray/programming/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Java: Sort lottery numbers in array</title>
		<link>https://pixelfriedhof.com/en/java-sort-lottery-numbers-in-array/</link>
					<comments>https://pixelfriedhof.com/en/java-sort-lottery-numbers-in-array/#respond</comments>
		
		<dc:creator><![CDATA[megaadmin]]></dc:creator>
		<pubDate>Wed, 20 Mar 2019 17:26:14 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">http://pixelfriedhof.com/?p=206</guid>

					<description><![CDATA[<p>This class generates lottery numbers and reads them into an array.<br />The values contained in the array are then sorted in ascending order.</p>
<p> </p>
<p>Der Beitrag <a href="https://pixelfriedhof.com/en/java-sort-lottery-numbers-in-array/">Java: Sort lottery numbers in array</a> erschien zuerst auf <a href="https://pixelfriedhof.com/en">Pixelfriedhof</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This class generates lottery numbers and reads them into an array.<br />
The values contained in the array are then sorted in ascending order.</p>
<p>In the meantime, I&#8217;ve been raging like a lunatic on the living room table 🙂 I followed the wrong approach for 4 hours and then moved on to first reading in, then sorting out. Now it works.</p>
<pre xml:lang="java">[code]public class LotterynumberenArraySortierung {

public static void main(String[] args) {

// TODO Auto-generated method stub

boolean[] drawnball;

int[] lotterynumbers;

int randomnumber;

int swap;

lotterynumbers= new int[6];

drawnball= new boolean[49];

//Assignment of values to the array

for ( int i =0; i &lt; lotterynumbers.length; i ++){

if (i==0){

randomnumber=(int) (Math.random()*49+1);

lotterynumbers[0]=randomnumber;

drawnball[randomnumber-1]=true;

}

randomnumber=(int) (Math.random()*49+1);

while (drawnball[randomnumber-1]==true){

randomnumber=(int) (Math.random()*49+1);

}

drawnball[randomnumber-1]=true;

lotterynumbers[i] = randomnumber;

}

//Sort the values within the array using a bubble sort-like method

for (int i=0; i &lt; lotterynumbers.length-1; i=i+1) 

 for (int c=lotterynumbers.length-1; c &gt; i; c=c-1) 

 if (lotterynumbers[c-1] &gt; lotterynumbers[c]) 

 {

 

 //The number to be swapped is temporarily stored under the variable swap to free its space.

 swap = lotterynumbers[c-1]; 

 

 //Old number is exchanged for new one

 lotterynumbers[c-1] = lotterynumbers[c]; 

 

 //swap is used at the rear

 lotterynumbers[c] = swap; 

 }

// Output of contents

for ( int i =0; i &lt;= 5; i ++){

System.out.println("Lotterynumber " + (i+1) + " ist: " + lotterynumbers[i]);

}

}

}

 [/code]</pre>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;">
<p>Der Beitrag <a href="https://pixelfriedhof.com/en/java-sort-lottery-numbers-in-array/">Java: Sort lottery numbers in array</a> erschien zuerst auf <a href="https://pixelfriedhof.com/en">Pixelfriedhof</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://pixelfriedhof.com/en/java-sort-lottery-numbers-in-array/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Java: Lottery number generator with array usage</title>
		<link>https://pixelfriedhof.com/en/java-lottery-number-generator-with-array-usage/</link>
					<comments>https://pixelfriedhof.com/en/java-lottery-number-generator-with-array-usage/#respond</comments>
		
		<dc:creator><![CDATA[megaadmin]]></dc:creator>
		<pubDate>Wed, 20 Mar 2019 16:26:14 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">http://pixelfriedhof.com/?p=205</guid>

					<description><![CDATA[<p>This Java class generates 6 lottery numbers and stores them in an array.<br />The class ensures that no numbers are drawn twice.</p>
<p>Der Beitrag <a href="https://pixelfriedhof.com/en/java-lottery-number-generator-with-array-usage/">Java: Lottery number generator with array usage</a> erschien zuerst auf <a href="https://pixelfriedhof.com/en">Pixelfriedhof</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This Java class generates 6 lottery numbers and stores them in an array.<br />
The class ensures that no numbers are drawn twice.</p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;">
<pre xml:lang="java">[code]public class LotterynumbersArray {

public static void main(String[] args) {

// TODO Auto-generated method stub

boolean[] drawnball;

int[] lotterynumbers;

int randomnumber =0;

lotterynumbers= new int[6];

drawnball= new boolean[49];

for ( int i =0; i &lt; lotterynumbers.length; i ++){

if (i==0){

randomnumber=(int) (Math.random()*49+1);

lotterynumbers[0]=randomnumber;

drawnball[randomnumber-1]=true;

}

randomnumber=(int) (Math.random()*49+1);

while (drawnball[randomnumber-1]==true){

randomnumber=(int) (Math.random()*49+1);

}

drawnball[randomnumber-1]=true;

lotterynumbers[i] = randomnumber;

}

for ( int i =0; i &lt;= 5; i ++){

System.out.println("Lotterynumber " + (i+1) + " is: " + lotterynumbers[i]);

}

}

}

 [/code]</pre>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;">
<p style="margin: 0px; font-size: 11px; font-family: Monaco;">
<p style="margin: 0px; font-size: 11px; font-family: Monaco;">
<p>Der Beitrag <a href="https://pixelfriedhof.com/en/java-lottery-number-generator-with-array-usage/">Java: Lottery number generator with array usage</a> erschien zuerst auf <a href="https://pixelfriedhof.com/en">Pixelfriedhof</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://pixelfriedhof.com/en/java-lottery-number-generator-with-array-usage/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
