mirror of https://github.com/01-edu/public.git
Xavier Petit
4 years ago
committed by
xpetit
20 changed files with 77 additions and 130 deletions
@ -1,33 +1,14 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"os" |
||||
|
||||
"github.com/01-edu/z01" |
||||
) |
||||
|
||||
func printStr(str string) { |
||||
arrayStr := []rune(str) |
||||
|
||||
for i := 0; i < len(arrayStr); i++ { |
||||
z01.PrintRune(arrayStr[i]) |
||||
} |
||||
z01.PrintRune('\n') |
||||
} |
||||
|
||||
func isEven(nbr int) bool { |
||||
return nbr%2 == 0 |
||||
} |
||||
|
||||
func main() { |
||||
EvenMsg := "I have an even number of arguments" |
||||
OddMsg := "I have an odd number of arguments" |
||||
|
||||
lenOfArg := len(os.Args) - 1 |
||||
|
||||
if isEven(lenOfArg) { |
||||
printStr(EvenMsg) |
||||
if len(os.Args)-1%2 == 0 { |
||||
fmt.Println("I have an even number of arguments") |
||||
} else { |
||||
printStr(OddMsg) |
||||
fmt.Println("I have an odd number of arguments") |
||||
} |
||||
} |
||||
|
@ -1,15 +1,15 @@
|
||||
package main |
||||
|
||||
import "github.com/01-edu/z01" |
||||
import "fmt" |
||||
|
||||
func main() { |
||||
diff := 'a' - 'A' |
||||
for c := 'a'; c <= 'z'; c++ { |
||||
if c%2 == 0 { |
||||
z01.PrintRune(c - diff) |
||||
fmt.Printf("%c", c-diff) |
||||
} else { |
||||
z01.PrintRune(c) |
||||
fmt.Printf("%c", c) |
||||
} |
||||
} |
||||
z01.PrintRune('\n') |
||||
fmt.Println() |
||||
} |
||||
|
@ -1,15 +1,15 @@
|
||||
package main |
||||
|
||||
import "github.com/01-edu/z01" |
||||
import "fmt" |
||||
|
||||
func main() { |
||||
diff := 'a' - 'A' |
||||
for c := 'z'; c >= 'a'; c-- { |
||||
if c%2 == 0 { |
||||
z01.PrintRune(c) |
||||
fmt.Printf("%c", c) |
||||
} else { |
||||
z01.PrintRune(c - diff) |
||||
fmt.Printf("%c", c-diff) |
||||
} |
||||
} |
||||
z01.PrintRune('\n') |
||||
fmt.Println() |
||||
} |
||||
|
@ -1,7 +1,7 @@
|
||||
package main |
||||
|
||||
import "github.com/01-edu/z01" |
||||
import "fmt" |
||||
|
||||
func main() { |
||||
z01.PrintRune('a') |
||||
fmt.Print("a") |
||||
} |
||||
|
@ -1,7 +1,7 @@
|
||||
package main |
||||
|
||||
import "github.com/01-edu/z01" |
||||
import "fmt" |
||||
|
||||
func main() { |
||||
z01.PrintRune('z') |
||||
fmt.Print("z") |
||||
} |
||||
|
@ -1,10 +1,10 @@
|
||||
package main |
||||
|
||||
import "github.com/01-edu/z01" |
||||
import "fmt" |
||||
|
||||
func main() { |
||||
for i := '0'; i <= '9'; i++ { |
||||
z01.PrintRune(i) |
||||
fmt.Printf("%c", i) |
||||
} |
||||
z01.PrintRune('\n') |
||||
fmt.Println() |
||||
} |
||||
|
@ -1,23 +1,22 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"os" |
||||
"unicode" |
||||
|
||||
"github.com/01-edu/z01" |
||||
) |
||||
|
||||
func main() { |
||||
if len(os.Args) == 2 { |
||||
for _, r := range os.Args[1] { |
||||
z01.PrintRune(r) |
||||
fmt.Printf("%c", r) |
||||
if unicode.IsLetter(r) { |
||||
rep := unicode.ToLower(r) - 'a' |
||||
for i := 0; i < int(rep); i++ { |
||||
z01.PrintRune(r) |
||||
fmt.Printf("%c", r) |
||||
} |
||||
} |
||||
} |
||||
z01.PrintRune('\n') |
||||
fmt.Println() |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue