\documentclass{ctexbeamer}
\usepackage{listings}
\title{测试}
\author{XXX}
\date{\today}
\lstset {
basicstyle=\ttfamily
keywordstyle=\bfseries\ttfamily
commentstyle=\rmfamily\itshape
stringstyle=\sffamily
}
\begin{document}
\begin{frame}
\maketitle
\end{frame}
\date{\today}
\begin{frame}{我是标题}{我是副标题}
正文正文正文正文\\正文正文正文正文正文\\
正文正文正文正文\\正文正文正文正文正文\\
正文正文正文正文\\正文正文正文正文正文
\end{frame}
\begin{frame}[fragile]{代码}
\begin{block}{一段代码}
\begin{lstlisting}[language=C++]
// hello.cpp
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}
\end{lstlisting}
\end{block}
\end{frame}
\end{document}