modified codes

This commit is contained in:
2025-05-04 05:59:50 +00:00
parent 08b885e397
commit 64c4a1af4d
25 changed files with 91 additions and 22 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-14
View File
@@ -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; double x;
printf("Int n: "); scanf("%d", &n); 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("Integer n is %f\n", n);
printf("Double percision floating point decimal x is %f\n", x); printf("Double percision floating point decimal x is %f\n", x);
+14
View 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; double x;
printf("Int n: "); scanf("%d", &n); 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("Integer n is %d\n", n);
printf("Double percision floating point decimal x is %d\n", x); printf("Double percision floating point decimal x is %d\n", x);
@@ -5,7 +5,7 @@ int main(void) {
double x; double x;
printf("Int n: "); scanf("%d", &n); 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("Integer n is %d\n", n);
printf("Double percision floating point decimal x is %lf\n", x); printf("Double percision floating point decimal x is %lf\n", x);
@@ -5,7 +5,7 @@ int main(void) {
double x; double x;
printf("Int n: "); scanf("%f", &n); 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("Integer n is %d\n", n);
printf("Double percision floating point decimal x is %f\n", x); printf("Double percision floating point decimal x is %f\n", x);
@@ -5,7 +5,7 @@ int main(void) {
double x; double x;
printf("Int n: "); scanf("%lf", &n); 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("Integer n is %d\n", n);
printf("Double percision floating point decimal x is %f\n", x); printf("Double percision floating point decimal x is %f\n", x);
@@ -5,7 +5,7 @@ int main(void) {
double x; double x;
printf("Int n: "); scanf("%d", &n); 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("Integer n is %d\n", n);
printf("Double percision floating point decimal x is %f\n", x); printf("Double percision floating point decimal x is %f\n", x);
@@ -5,7 +5,7 @@ int main(void) {
double x; double x;
printf("Int n: "); scanf("%d", &n); 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("Integer n is %d\n", n);
printf("Double percision floating point decimal x is %f\n", x); printf("Double percision floating point decimal x is %f\n", x);
+1 -1
View File
@@ -5,7 +5,7 @@ int main(void) {
double x; double x;
printf("Int n: "); scanf("%d", &n); 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("Integer n is %d\n", n);
printf("Double percision floating point decimal x is %f\n", x); printf("Double percision floating point decimal x is %f\n", x);
+4
View File
@@ -0,0 +1,4 @@
10
25.3
Binary file not shown.
Binary file not shown.
Binary file not shown.
+65
View 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}