v3
This commit is contained in:
parent
7881c5b11f
commit
c5b526ec44
29
Kontrollstrukturen/afg3 sieb/.gitignore
vendored
Normal file
29
Kontrollstrukturen/afg3 sieb/.gitignore
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
Kontrollstrukturen/afg3 sieb/.idea/.gitignore
vendored
Normal file
8
Kontrollstrukturen/afg3 sieb/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
6
Kontrollstrukturen/afg3 sieb/.idea/misc.xml
Normal file
6
Kontrollstrukturen/afg3 sieb/.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Kontrollstrukturen/afg3 sieb/.idea/modules.xml
Normal file
8
Kontrollstrukturen/afg3 sieb/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/afg3 sieb.iml" filepath="$PROJECT_DIR$/afg3 sieb.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
Kontrollstrukturen/afg3 sieb/.idea/vcs.xml
Normal file
6
Kontrollstrukturen/afg3 sieb/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
11
Kontrollstrukturen/afg3 sieb/afg3 sieb.iml
Normal file
11
Kontrollstrukturen/afg3 sieb/afg3 sieb.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
40
Kontrollstrukturen/afg3 sieb/src/Main.java
Normal file
40
Kontrollstrukturen/afg3 sieb/src/Main.java
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Main {
|
||||
|
||||
// =====================
|
||||
// Sieb des Erathostenes (kopiert von Matti)
|
||||
// =====================
|
||||
|
||||
public static void main(String[] args){
|
||||
int MAXIMUM = 100;
|
||||
int MAX_PER_ROW = 20;
|
||||
|
||||
boolean[] primes = new boolean[MAXIMUM];
|
||||
|
||||
Arrays.fill(primes, true);
|
||||
|
||||
for(int i=2; i < MAXIMUM * 0.5; i++){
|
||||
for(int j=2; j < MAXIMUM; j++){
|
||||
|
||||
int index = i * j;
|
||||
|
||||
if(index < MAXIMUM && index > 0){
|
||||
primes[index] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
for(int i=0; i < primes.length; i++){
|
||||
if(primes[i] && i > 1) {
|
||||
System.out.print(i + " ");
|
||||
counter++;
|
||||
if (counter % MAX_PER_ROW == 0) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user