Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. )
  6.  
  7. const a int = 1
  8.  
  9. type student struct {
  10. nome string
  11. sobrenome string
  12. matricula string
  13. idade int
  14. }
  15.  
  16. func main() {
  17. var b = 2
  18. fmt.Println("Constante", a)
  19. fmt.Println("Variável", b)
  20. fmt.Println("Loop")
  21. for i:=1; i <= 5; i++ {
  22. fmt.Println(i)
  23. }
  24.  
  25. imprimeAlunos()
  26.  
  27. fmt.Println("\nImprime somente pares")
  28. for j := 1; j <= 30; j++ {
  29. if j % 2 == 0{
  30. fmt.Println(j)
  31. }
  32. }
  33. }
  34.  
  35. func imprimeAlunos() {
  36. aluno1 := student{nome: "Marlon", sobrenome: "Baptista de Quadros", matricula: "12324565441", idade: 26}
  37. aluno2 := student{nome: "Fulano", sobrenome: "Da Silva Sauro", matricula: "123456465416", idade: 20}
  38. aluno3 := student{nome: "Ciclano", sobrenome: "De Souza", matricula: "13456478899", idade: 19}
  39.  
  40. alunos := make([]student, 3)
  41.  
  42. alunos[0] = aluno1
  43. alunos[1] = aluno2
  44. alunos[2] = aluno3
  45.  
  46. fmt.Println("\n" + aluno1.nome)
  47. fmt.Println(aluno1.sobrenome)
  48. fmt.Println(aluno1.nome , aluno1.sobrenome + "\n")
  49.  
  50. for k := 0; k < len(alunos); k++{
  51. fmt.Println(alunos[k])
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement