A tour of Go exercise: slices

Source: Internet
Author: User

ImplementPic. It shoshould return a slice of Lengthdy, Each element of which is a slicedx8-bit unsigned integers. When you run the program, it will display your picture, interpreting the integers as grayscale (well, bluescale) values.

The choice of image is up to you. Interesting functions includex^y,(x+y)/2, Andx*y.

(You need to use a loop to allocate each[]uint8Inside[][]uint8.)

(Useuint8(intValue)To convert between types.

 

package mainimport "code.google.com/p/go-tour/pic"func Pic(dx, dy int) [][]uint8 {    s := make([][]uint8,dx)    for i := range s {        s[i] = make([]uint8,dy)        for j := range s[i]{            s[i][j] = uint8(i * j)        }    }    return s}func main() {    pic.Show(Pic)}

 

A tour of Go exercise: slices

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.