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

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.
主站蜘蛛池模板: 芜湖市| 定南县| 英吉沙县| 卫辉市| 五台县| 铁岭县| 苍梧县| 霍山县| 墨竹工卡县| 伊宁市| 丁青县| 无棣县| 吉首市| 隆尧县| 宁远县| 武川县| 昌乐县| 日喀则市| 聊城市| 枣阳市| 且末县| 西平县| 潼关县| 孝义市| 辽阳县| 厦门市| 绍兴市| 弋阳县| 炎陵县| 吴川市| 巴中市| 重庆市| 宁远县| 卢湾区| 鞍山市| 双辽市| 阿尔山市| 泰和县| 双鸭山市| 九龙城区| 改则县|