Ladies_Man

Визуал. авт. Мили (Vis_Mealy)

May 17th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.39 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. type state struct {
  5.     in  int
  6.     out string
  7. }
  8.  
  9. func main() {
  10.     var n, m, q_start int
  11.     fmt.Scanf("%d\n%d\n%d\n", &n, &m, &q_start)
  12.     M := make([][]state, n)
  13.     for i := 0; i < n; i++ { M[i] = make([]state, m) }
  14.     for i := 0; i < n; i++ { for j := 0; j < m; j++ { fmt.Scanf("%d", &M[i][j].in) }; fmt.Scanf("\n") }
  15.     for i := 0; i < n; i++ { for j := 0; j < m; j++ { fmt.Scanf("%s", &M[i][j].out) }; fmt.Scanf("\n") }
  16.     fmt.Printf("digraph {\n\trankdir = LR\n\tdummy [label = \"\", shape = none]\n")
  17.     for i := 0; i < n; i++ { fmt.Printf("\t%d [shape = circle]\n", i) }
  18.     fmt.Printf("\tdummy -> %d\n", q_start)
  19.     for i := 0; i < n; i++ {
  20.         for j := 0; j < m; j++ { fmt.Printf("\t%d -> %d [label = \"%c(%s)\"]\n", i, M[i][j].in, 'a'+j, M[i][j].out) }
  21.     }
  22.     fmt.Printf("}")
  23. }
  24. /*
  25. in:
  26. 4
  27. 3
  28. 0
  29. 1 3 3
  30. 1 1 2
  31. 2 2 2
  32. 1 2 3
  33. x y y
  34. y y x
  35. x x x
  36. x y y
  37. */
  38. /*
  39. out:
  40. digraph {
  41.     rankdir = LR
  42.     dummy [label = "", shape = none]
  43.     0 [shape = circle]
  44.     1 [shape = circle]
  45.     2 [shape = circle]
  46.     3 [shape = circle]
  47.     dummy -> 0
  48.     0 -> 1 [label = "a(x)"]
  49.     0 -> 3 [label = "b(y)"]
  50.     0 -> 3 [label = "c(y)"]
  51.     1 -> 1 [label = "a(y)"]
  52.     1 -> 1 [label = "b(y)"]
  53.     1 -> 2 [label = "c(x)"]
  54.     2 -> 2 [label = "a(x)"]
  55.     2 -> 2 [label = "b(x)"]
  56.     2 -> 2 [label = "c(x)"]
  57.     3 -> 1 [label = "a(x)"]
  58.     3 -> 2 [label = "b(y)"]
  59.     3 -> 3 [label = "c(y)"]
  60. }
  61. */
Advertisement
Add Comment
Please, Sign In to add comment