9 Example:\documentclass[a4paper,10pt]{article}
\usepackage{fancybox}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{times}
\begin{document}
\section{Counting Numbers of Uppercase Characters}
\begin{center}
\begin{lstlisting}[language={[ANSI]C},
numbers=left,
numberstyle=\tiny,
basicstyle=\small\ttfamily,
stringstyle=\color{purple},
keywordstyle=\color{blue}\bfseries,
commentstyle=\color{olive},
directivestyle=\color{blue},
frame=shadowbox,
%framerule=0pt,
%backgroundcolor=\color{pink},
%rulesepcolor=\color{red!20!green!20!blue!20}
%rulesepcolor=\color{brown}
%xleftmargin=2em,xrightmargin=2em,aboveskip=1em
]
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
#define SIZE 26
int
main (int argc, char *argv[])
{
int array[SIZE];
int i;
char c;
for (i = 0; i < SIZE; i++)
array[i] = 0;
while ((c = getchar ()) != EOF)
{
if (isupper (c))
{
array[c - 'A']++;
}
}
for (i = 0; i < 26; i++)
printf ("%c:]\n", (char) ('A' + i), array[i]);
return 0;
}
\end{lstlisting}
\end{center}
\end{document}
发表评论 取消回复