PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgo / misc / cgo / life / main.go
blob45376fd05a97fde57588e534105dd144e41c1ae3
1 // cmpout -tags=use_go_run
3 // Copyright 2010 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // +build test_run
9 // Run the game of life in C using Go for parallelization.
11 package main
13 import (
14 "flag"
15 "fmt"
17 "."
20 const MAXDIM = 100
22 var dim = flag.Int("dim", 16, "board dimensions")
23 var gen = flag.Int("gen", 10, "generations")
25 func main() {
26 flag.Parse()
28 var a [MAXDIM * MAXDIM]int32
29 for i := 2; i < *dim; i += 8 {
30 for j := 2; j < *dim-3; j += 8 {
31 for y := 0; y < 3; y++ {
32 a[i**dim+j+y] = 1
37 life.Run(*gen, *dim, *dim, a[:])
39 for i := 0; i < *dim; i++ {
40 for j := 0; j < *dim; j++ {
41 if a[i**dim+j] == 0 {
42 fmt.Print(" ")
43 } else {
44 fmt.Print("X")
47 fmt.Print("\n")