Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. // You can edit this code!
  2. // Click here and start typing.
  3. package main
  4.  
  5. import "fmt"
  6.  
  7. func max(a, b float32) float32 {
  8. if a > b {
  9. return a
  10. }
  11.  
  12. return b
  13. }
  14. func main() {
  15. var a, b, c float32
  16.  
  17. fmt.Print("Введіть а: ")
  18. fmt.Scan(&a)
  19. fmt.Print("Введіть b: ")
  20. fmt.Scan(&b)
  21. fmt.Print("Введіть c: ")
  22. fmt.Scan(&c)
  23.  
  24. fmt.Println((max(a, a+b) + max(b, b+c)) / (1 + max(a+b*c, 1.15)))
  25.  
  26. }
  27.  
  28. func main5() {
  29. var n int
  30.  
  31. fmt.Print("Введіть розмір матриці ")
  32. fmt.Scan(&n)
  33.  
  34. matrix := make([][]int, n)
  35.  
  36. for i := 0; i < n; i++ {
  37. matrix[i] = make([]int, n)
  38. }
  39.  
  40. for i := 0; i < n; i++ {
  41. for j := 0; j < n; j++ {
  42. fmt.Print("Matrix [", i, "][", j, "]: ")
  43. fmt.Scan(&matrix[i][j])
  44. }
  45. }
  46.  
  47. for i := 0; i < n; i++ {
  48. for j := 0; j < n; j++ {
  49. fmt.Print(matrix[i][j], " ")
  50. }
  51.  
  52. fmt.Println("")
  53. }
  54.  
  55. var result int
  56.  
  57. for i := 0; i < n; i++ {
  58. for j := 0; j <= i/2; j++ {
  59. result += matrix[i][j]
  60. }
  61. }
  62.  
  63. fmt.Println(result)
  64. }
  65.  
  66. func main6() {
  67.  
  68. var n int = 25
  69.  
  70. fmt.Print("Введіть розмірність массиву ")
  71. fmt.Scan(&n)
  72.  
  73. number_line := make([]int, n)
  74.  
  75. for i := 0; i < n; i++ {
  76.  
  77. fmt.Print("Number [", i, "]: ")
  78. fmt.Scan(&number_line[i])
  79. }
  80.  
  81. var count int = 0
  82. var result_array = make([]int, 0)
  83.  
  84. for i := 0; i < n; i++ {
  85.  
  86. if number_line[i] == 0 {
  87. count += 1
  88. } else {
  89.  
  90. result_array = append(result_array, count)
  91.  
  92. count = 0
  93. }
  94. }
  95. fmt.Println(number_line)
  96. fmt.Println(getMax(result_array))
  97. }
  98.  
  99. func getMax(a []int) int {
  100. var max int = 0
  101. for i := 0; i < len(a); i++ {
  102. if max < a[i] {
  103. max = a[i]
  104. }
  105. }
  106.  
  107. return max
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement