Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 80ff4e6

Browse files
author
hengxin
committed
josephus.tex: control-flow, function
1 parent 9c0a2c3 commit 80ff4e6

12 files changed

+85
-23
lines changed

‎qrcode-programming-tutorial.png

370 Bytes
Loading[フレーム]
-84.6 KB
Binary file not shown.
370 Bytes
Loading[フレーム]

‎tutorial/josephus/figs/thankyou.png

3.96 KB
Loading[フレーム]

‎tutorial/josephus/josephus-handout.pdf

182 KB
Binary file not shown.

‎tutorial/josephus/josephus.pdf

5.85 KB
Binary file not shown.

‎tutorial/josephus/josephus.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
\subtitle{The Josephus Puzzle}
88

99
\author[Hengfeng Wei]{\large 魏恒峰}
10-
%\titlegraphic{\includegraphics[height = 1.8cm]{figs/20171016-logic-qrcode.png}}
10+
\titlegraphic{\includegraphics[height = 2.0cm]{figs/qrcode-programming-tutorial.png}}
1111
\institute{hfwei@nju.edu.cn}
1212
\date{2017年10月27日}
1313

@@ -27,6 +27,7 @@
2727
\input{parts/function}
2828
\input{parts/control-flow}
2929
\input{parts/array}
30+
\thankyou{}
3031

3132
\end{document}
3233
%%%%%%%%%%

‎tutorial/josephus/parts/array.tex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
%%%%%%%%%%%%%%%
2828

2929
%%%%%%%%%%%%%%%
30-
\begin{frame}{Array as Parameters}
30+
\begin{frame}[fragile]{Array as Parameters}
31+
\begin{lstlisting}[style = Cstyle]
32+
f(arr);
33+
34+
void f(int arr[]);
35+
36+
void f(int *arr);
37+
\end{lstlisting}
3138
\end{frame}
3239
%%%%%%%%%%%%%%%

‎tutorial/josephus/parts/control-flow.tex

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,59 @@
55
%%%%%%%%%%%%%%%
66

77
%%%%%%%%%%%%%%%
8-
\begin{frame}{\texttt{if}}
9-
10-
\end{frame}
11-
%%%%%%%%%%%%%%%
12-
13-
%%%%%%%%%%%%%%%
14-
\begin{frame}[fragile]{\texttt{switch}}
8+
\begin{frame}[fragile]{\texttt{if; switch, case}}
9+
\begin{columns}
10+
\column{0.45\textwidth}
11+
\begin{lstlisting}[style = Cstyle]
12+
if (condition A) {
13+
...
14+
} else if (condition B) {
15+
...
16+
} else { // $\lnot A \lor \lnot B$
17+
...
18+
}
19+
\end{lstlisting}
20+
\column{0.45\textwidth}
21+
\begin{lstlisting}[style = Cstyle]
22+
switch () {
23+
case c1:
24+
...
25+
break;
26+
case c2:
27+
...
28+
break;
29+
default:
30+
}
31+
\end{lstlisting}
32+
\end{columns}
1533
\end{frame}
1634
%%%%%%%%%%%%%%%
1735

1836
%%%%%%%%%%%%%%%
1937
\begin{frame}[fragile]{\texttt{for}}
38+
\begin{lstlisting}[style = Cstyle]
39+
for (int i = 0; i < n; ++i) {
40+
...
41+
}
42+
\end{lstlisting}
2043
\end{frame}
2144
%%%%%%%%%%%%%%%
2245

2346
%%%%%%%%%%%%%%%
2447
\begin{frame}[fragile]{\texttt{while}}
25-
\end{frame}
26-
%%%%%%%%%%%%%%%
27-
28-
%%%%%%%%%%%%%%%
29-
\begin{frame}[fragile]{\texttt{do while}}
30-
\end{frame}
31-
%%%%%%%%%%%%%%%
32-
33-
%%%%%%%%%%%%%%%
34-
\begin{frame}[fragile]{\texttt{goto}}
48+
\begin{columns}
49+
\column{0.45\textwidth}
50+
\begin{lstlisting}[style = Cstyle]
51+
while (condition) {
52+
...
53+
}
54+
\end{lstlisting}
55+
\column{0.45\textwidth}
56+
\begin{lstlisting}[style = Cstyle]
57+
do {
58+
...
59+
} while (condition);
60+
\end{lstlisting}
61+
\end{columns}
3562
\end{frame}
3663
%%%%%%%%%%%%%%%

‎tutorial/josephus/parts/function.tex

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
int solve_josephus(int n);
1111
\end{lstlisting}
1212

13+
\vspace{0.20cm}
14+
\stylebox{Making function names verbs.}
15+
1316
\vspace{0.20cm}
1417
\begin{lstlisting}[style = Cstyle]
1518
int main(void) {
@@ -32,16 +35,22 @@
3235
\begin{frame}[fragile]{Variables and Scopes}
3336
Variables:
3437
\begin{enumerate}
35-
\item external variables
36-
\item automatic variables
37-
\item parameters
38+
\item Automatic variables
39+
\item Parameters
40+
\item External variables
3841
\end{enumerate}
42+
43+
\vspace{0.60cm}
44+
\pause
45+
\stylebox{You shall always initialize variables. Always. Every time.}
3946
\end{frame}
4047
%%%%%%%%%%%%%%%
4148

4249
%%%%%%%%%%%%%%%
4350
\begin{frame}[fragile]{Pass by Value}
4451
\begin{lstlisting}[style = Cstyle]
52+
swap(a, b);
53+
4554
void swap(int a, int b) {
4655
int temp = a;
4756
a = b;
@@ -52,11 +61,17 @@
5261
\vspace{0.40cm}
5362
\pause
5463
\begin{lstlisting}[style = Cstyle]
64+
swap(&a, &b);
65+
5566
void swap(int *a, int *b) {
5667
int temp = *a;
5768
*a = *b;
5869
*b = tmp;
5970
}
6071
\end{lstlisting}
72+
73+
\vspace{0.30cm}
74+
\pause
75+
\stylebox{Place the * close to the variable name not pointer type.}
6176
\end{frame}
6277
%%%%%%%%%%%%%%%

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /