diff --git a/Aufgabe1/circle.go b/Aufgabe1/circle.go new file mode 100644 index 0000000..e20da9f --- /dev/null +++ b/Aufgabe1/circle.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "math" +) + +type Circle struct { + radius float64 +} + +func main() { + circle := Circle{radius: 6.4} + circumference := 2 * math.Pi * circle.radius + fmt.Println(circumference) +} diff --git a/Aufgabe1/test.go b/Aufgabe1/test.go deleted file mode 100644 index 95eefaa..0000000 --- a/Aufgabe1/test.go +++ /dev/null @@ -1,6 +0,0 @@ -package main - -import "fmt" - -//Idee: Wordcount nutzt forloops und bisschen logik - diff --git a/Aufgabe2/wordcount.go b/Aufgabe2/wordcount.go new file mode 100644 index 0000000..184253f --- /dev/null +++ b/Aufgabe2/wordcount.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "strings" +) + +func main() { + fruits := "ananas orange apfel apfel\n aprikose kirche" + + words := strings.Split(fruits, " ") + + wordCount := make(map[string]int) + + for _, word := range words { + word = strings.ReplaceAll(word, "\n", ""); // Wenn man newlines entfernen will + if strings.HasPrefix(word, "a") { + wordCount[word]++ + } + } + + for word, count := range wordCount { + fmt.Printf("%T: %v \n", word, count); + } +} diff --git a/Aufgabe3/channelZählen.go b/Aufgabe3/channelZählen.go new file mode 100644 index 0000000..c9c4672 --- /dev/null +++ b/Aufgabe3/channelZählen.go @@ -0,0 +1,26 @@ +package main + +import "fmt" + +func count(start, end int, ch chan int) { + for i := start; i <= end; i++ { + ch <- i + } +} + +func printCh(ch chan int) { + for i := 0; i < 10; i++ { + fmt.Println(<-ch) + } +} + +func main() { + channel1to5 := make(chan int) + channel6to10 := make(chan int) + + go count(1, 10, channel1to5) + go count(6, 10, channel6to10) + + printCh(channel1to5) + printCh(channel6to10) +} diff --git a/KompliziertereAufgabe/main.go b/KompliziertereAufgabe/main.go deleted file mode 100644 index e69de29..0000000 diff --git a/Vortrag/bascis.go b/bascis.go similarity index 85% rename from Vortrag/bascis.go rename to bascis.go index 3d7595e..ba3f210 100644 --- a/Vortrag/bascis.go +++ b/bascis.go @@ -26,6 +26,11 @@ func main() { fmt.Printf("%d + %d = %d \n", num2, num, result); + for i := 0; i <= 6; i++ { // Alle Zahlen von 0 - 6 + if i%2 == 0 { // Filtert nach gerade Zahlen + fmt.Println(i); + } + } text := "Willkommen zu unserem Go Vortrag!"; words := strings.Fields(text);