官术网_书友最值得收藏!

Exercises

  1. Browse the Go documentation site: https://golang.org/doc/.
  2. Write a Go program that keeps reading integers until you give the number 0 as input, then it prints the minimum and maximum integer in the input.
  3. Write the same Go program as before, but this time, you will get your input using command-line arguments. Which version do you think is better? Why?
  4. Write a Go program that supports two command-line options (-i and -k) in random order using if statements. Now change your program to support three command-line arguments. As you will see, the complexity of the latter program is just too much to handle using if statements.
  5. If the indices of a map were natural numbers, are there any cases that it would be wise and efficient to use a map instead of an array?
  6. Try to put the functionality of array2map.go into a separate function.
  7. Try to develop your own random number generator in Go that will still use the current time as a seed but not the math/rand package.
  8. Learn how to create a slice from an existing array. What happens when you make changes to the slice?
  9. Use the copy() function to make a copy of an existing slice. What happens when the destination slice is smaller than the source slice? What happens when the destination slice is bigger than the source slice?
  10. Try to write an interface for supporting points in 3D space. Then, use this interface to support points that reside on the x-axis.
主站蜘蛛池模板: 华宁县| 徐水县| 延边| 双桥区| 道真| 罗源县| 万州区| 时尚| 阜新市| 宁陵县| 石渠县| 罗平县| 佛坪县| 阳朔县| 秦安县| 杂多县| 新津县| 武宣县| 利川市| 贵州省| 老河口市| 武义县| 朝阳市| 江达县| 应城市| 库伦旗| 儋州市| 铁岭市| 佛教| 临湘市| 柏乡县| 简阳市| 祁东县| 武山县| 珠海市| 婺源县| 革吉县| 本溪市| 东至县| 汝城县| 文山县|