Un cours pour se lancer dans la programmation avec le langage Go (golang).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.3 KiB

  1. /* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
  2. Ecole du Logiciel Libre : https://e2li.org/
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or any
  6. later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>
  13. *******************************************************************/
  14. package main
  15. import "fmt"
  16. func main() {
  17. for i := 0; i < 5; i++ {
  18. fmt.Println(i)
  19. }
  20. for i := 0; ; {
  21. if i >= 5 {
  22. break
  23. }
  24. fmt.Println(i)
  25. i++
  26. }
  27. i := 0
  28. for i < 5 {
  29. fmt.Println(i)
  30. i++
  31. }
  32. i = 0
  33. for ; ; i++ {
  34. if i >= 5 {
  35. break
  36. }
  37. fmt.Println(i)
  38. }
  39. for i := 0; i < 5; {
  40. fmt.Println(i)
  41. i++
  42. }
  43. i = 0
  44. for ; i < 5; i++ {
  45. fmt.Println(i)
  46. }
  47. for i := 0; ; i++ {
  48. if i >= 5 {
  49. break
  50. }
  51. fmt.Println(i)
  52. }
  53. i = 0
  54. for {
  55. if i >= 5 {
  56. break
  57. }
  58. fmt.Println(i)
  59. i++
  60. }
  61. for i, j := 0, 10; i != j; i, j = i+1, j-1 {
  62. fmt.Println(i, j)
  63. }
  64. }