modified codes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,14 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n = 10;
|
||||
double x = 25.3;
|
||||
|
||||
printf("Int n: "); scanf("%d", &n);
|
||||
printf("Doble n: "); scanf("%f", &x);
|
||||
|
||||
printf("Integer n is %lf\n", n);
|
||||
printf("Double percision floating point decimal x is %f\n", x);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,7 @@ int main(void) {
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%d", &n);
|
||||
printf("Doble n: "); scanf("%f", &x);
|
||||
printf("Double x: "); scanf("%lf", &x);
|
||||
|
||||
printf("Integer n is %f\n", n);
|
||||
printf("Double percision floating point decimal x is %f\n", x);
|
||||
14
programs/printf-formats/main-p1-lf.c
Normal file
14
programs/printf-formats/main-p1-lf.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%d", &n);
|
||||
printf("Double x: "); scanf("%lf", &x);
|
||||
|
||||
printf("Integer n is %d\n", n);
|
||||
printf("Double percision floating point decimal x is %f\n", x);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ int main(void) {
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%d", &n);
|
||||
printf("Doble n: "); scanf("%f", &x);
|
||||
printf("Double x: "); scanf("%lf", &x);
|
||||
|
||||
printf("Integer n is %d\n", n);
|
||||
printf("Double percision floating point decimal x is %d\n", x);
|
||||
@@ -5,7 +5,7 @@ int main(void) {
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%d", &n);
|
||||
printf("Doble n: "); scanf("%f", &x);
|
||||
printf("Double x: "); scanf("%lf", &x);
|
||||
|
||||
printf("Integer n is %d\n", n);
|
||||
printf("Double percision floating point decimal x is %lf\n", x);
|
||||
@@ -5,7 +5,7 @@ int main(void) {
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%f", &n);
|
||||
printf("Doble n: "); scanf("%f", &x);
|
||||
printf("Double x: "); scanf("%lf", &x);
|
||||
|
||||
printf("Integer n is %d\n", n);
|
||||
printf("Double percision floating point decimal x is %f\n", x);
|
||||
@@ -5,7 +5,7 @@ int main(void) {
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%lf", &n);
|
||||
printf("Doble n: "); scanf("%f", &x);
|
||||
printf("Double x: "); scanf("%lf", &x);
|
||||
|
||||
printf("Integer n is %d\n", n);
|
||||
printf("Double percision floating point decimal x is %f\n", x);
|
||||
@@ -5,7 +5,7 @@ int main(void) {
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%d", &n);
|
||||
printf("Doble n: "); scanf("%lf", &x);
|
||||
printf("Double x: "); scanf("%d", &x);
|
||||
|
||||
printf("Integer n is %d\n", n);
|
||||
printf("Double percision floating point decimal x is %f\n", x);
|
||||
@@ -5,7 +5,7 @@ int main(void) {
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%d", &n);
|
||||
printf("Doble n: "); scanf("%d", &x);
|
||||
printf("Double x: "); scanf("%f", &x);
|
||||
|
||||
printf("Integer n is %d\n", n);
|
||||
printf("Double percision floating point decimal x is %f\n", x);
|
||||
@@ -5,7 +5,7 @@ int main(void) {
|
||||
double x;
|
||||
|
||||
printf("Int n: "); scanf("%d", &n);
|
||||
printf("Doble n: "); scanf("%f", &x);
|
||||
printf("Double x: "); scanf("%lf", &x);
|
||||
|
||||
printf("Integer n is %d\n", n);
|
||||
printf("Double percision floating point decimal x is %f\n", x);
|
||||
|
||||
4
programs/printf-formats/test.txt
Normal file
4
programs/printf-formats/test.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
10
|
||||
25.3
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
65
section/printf-formats.tex
Normal file
65
section/printf-formats.tex
Normal file
@@ -0,0 +1,65 @@
|
||||
\section{\texttt{double}型と\texttt{printf}関数・\texttt{scanf}関数の書式}
|
||||
|
||||
\defaultlistingstyle
|
||||
\lstinputlisting[language=C, title={変更元のソースコード}]{../programs/printf-formats/main.c}
|
||||
|
||||
上記のソースコードについて、\texttt{printf}関数と\texttt{scanf}関数の書式を次のように変更していく:
|
||||
|
||||
\begin{itemize}
|
||||
\item 第一の\texttt{printf}関数の書式を\texttt{\%f}にする
|
||||
\item 第一の\texttt{printf}関数の書式を\texttt{\%lf}にする
|
||||
\item 第二の\texttt{printf}関数の書式を\texttt{\%d}にする
|
||||
\item 第二の\texttt{printf}関数の書式を\texttt{\%lf}にする
|
||||
\item 第一の\texttt{scanf}関数の書式を\texttt{\%f}にする
|
||||
\item 第一の\texttt{scanf}関数の書式を\texttt{\%lf}にする
|
||||
\item 第二の\texttt{scanf}関数の書式を\texttt{\%d}にする
|
||||
\item 第二の\texttt{scanf}関数の書式を\texttt{\%f}にする
|
||||
\end{itemize}
|
||||
|
||||
\subsection{\texttt{main-p1-f}}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[width=\textwidth]{./assets/printf-formats/main-p1-f}
|
||||
\end{center}
|
||||
|
||||
\subsection{\texttt{main-p1-lf}}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[width=\textwidth]{./assets/printf-formats/main-p1-lf}
|
||||
\end{center}
|
||||
|
||||
\subsection{\texttt{main-p2-d}}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[width=\textwidth]{./assets/printf-formats/main-p2-d}
|
||||
\end{center}
|
||||
|
||||
\subsection{\texttt{main-p2-lf}}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[width=\textwidth]{./assets/printf-formats/main-p2-lf}
|
||||
\end{center}
|
||||
|
||||
\subsection{\texttt{main-s1-f}}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[width=\textwidth]{./assets/printf-formats/main-p3-f}
|
||||
\end{center}
|
||||
|
||||
\subsection{\texttt{main-s1-lf}}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[width=\textwidth]{./assets/printf-formats/main-p3-lf}
|
||||
\end{center}
|
||||
|
||||
\subsection{\texttt{main-s2-d}}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[width=\textwidth]{./assets/printf-formats/main-p4-d}
|
||||
\end{center}
|
||||
|
||||
\subsection{\texttt{main-s2-f}}
|
||||
|
||||
\begin{center}
|
||||
\includegraphics[width=\textwidth]{./assets/printf-formats/main-p4-f}
|
||||
\end{center}
|
||||
Reference in New Issue
Block a user