1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| \documentclass[a4paper, 11pt, twoside,openright]{report}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=4cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
text width=6em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
minimum height=2em]
\begin{figure}
\begin{tikzpicture}[node distance = 3cm, auto]
\node [cloud] (input) {Sell and buy order input};
\node[decision, below of=input] (while) {Reach end of any array?};
\node [block, right of=while, node distance=4cm] (result) {Output the order list};
\node[decision, below of =while] (price) {buyer price $\geq$ seller price?};
\node [decision, below of=price] (token) {buyer token $\leq$ seller token?};
\node [block, below of=token, node distance=4cm] (update1) {update token balance};
\node [block, below of = update1] (createAdd1) {create and add the record to order list};
\node[block, right of = token, node distance = 4cm] (update2) {update token balance};
\node[block, below of=update2] (createAdd2) {create and add the record to order list};
\node[block, below of=createAdd2] (nextb) {next buyer};
\node[decision, below of=nextb] (notoken) {token=0?};
\node[block, left of=price, node distance=4cm] (nexts2) {next seller};
\draw [line] (input) -- coordinate[midway](m1)(while);
\path [line] (input) -- (while);
\path [line] (while) -- node {yes}(result);
\path [line] (while) -- node {no} (price);
\path [line] (price) -- node {yes} (token);
\path [line] (token) -- node{no} (update1);
\path [line] (token) -- node {yes} (update2);
\path [line] (update1) -- (createAdd1);
\path [line] (createAdd1) -| (nexts2);
\path [line] (update2) -- (createAdd2);
\path [line] (createAdd2) -- (nextb);
\path [line] (nextb) -- (notoken);
\path [line] (notoken) -| node {yes} (nexts2);
\path [line] (price) -- node {no} (nexts2);
\path [line] (nexts2) |- (while);
\draw[line] (notoken.0) |- node {no}(m1);
\end{tikzpicture}
\caption{flowchart}
\label{fig:flowchart}
\end{figure}
\end{document} |
Partager