% !TEX TS-program = XeLaTeX
% Commands for running this example:
%      xelatex YOURFILENAME
% End of Commands
%Negin Sahraei, negin.sahraei@gmail.com
%For more info about "listings" package you can type 'texdoc listings' in your cmd(command prompt), this command will show u the PDF file associated with the package
\documentclass{minimal}
\usepackage{color,xecolor}
\usepackage{etoolbox}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{xepersian}

\begin{document}
\pagestyle{empty}
\newpage
\lstset{language=C++ , %behet mige ke zabooni ke dari bahash barnamehato minevisi chie , intori khod be khod keywords ro shenasayi mikone 
keywordstyle=\color{blue!70}\bfseries,% bold blue keywords  , chon gofti keyworset blue bashe , hala man boldesham kardam age nakhasti boldesho vardar
basicstyle=\small, % print whole listing small baees mishe codehat nesbat be neveshte motenaseb bashan o andaze neveshte nashan 
identifierstyle=, % nothing happens
commentstyle=\color{olive}, % white comments , range comment ha ro taeen mikone 
stringstyle=\color{purple!70}\ttfamily , % typewriter type for strings , range string ha ro taeen miko n
showstringspaces=false , % no special string spaces 
frameround=fttt ,% Defines the shape of the frame  , shekle frame hato mige age khasti framet shekle digeyi bashe az roo rahnamash avaz kon 
 backgroundcolor=\color{gray!10},% Defines the color of the background  , range dakhele boxio mige ke toosh dari code mizani 
morecomment=[s][\color{olive}]{/*}{*/} }% Defines the color of your comments , dastoorate jadidi ke bayad comment hesaaab shan o rangeshoono mige 

\lstset{literate=%
   *{0}{{{\color{red!20!violet}0}}}1
    {1}{{{\color{red!20!violet}1}}}1
    {2}{{{\color{red!20!violet}2}}}1
    {3}{{{\color{red!20!violet}3}}}1
    {4}{{{\color{red!20!violet}4}}}1
    {5}{{{\color{red!20!violet}5}}}1
    {6}{{{\color{red!20!violet}6}}}1
    {7}{{{\color{red!20!violet}7}}}1
    {8}{{{\color{red!20!violet}8}}}1
    {9}{{{\color{red!20!violet}9}}}1
} % in dare mige agar man adad dashtam banafshesh kon amma agar in adad too string bood ham range string bashe na banafsh 

\section{توضیحات }
تمارین با استفاده از سبک 
\lr{Listings}
تایپ شده‌اند . 
این سبک برای برنامه‌نویسانی که تمایل دارند کد‌های خود را با استفاده از نرم‌افزار  لاتک تایپ کنند طراحی شده و تقریبا تمام امکاناتی که یک برنامه‌نویس لازم دارد را در اختیار ما قرار می‌دهد . 
برای مثال در این تمرینات که من از زبان 
\lr{C++}
استفاده کرده‌ام ، با استفاده از تنظیمات این زبان را برای کد زدن انتخاب کرده‌ام . همچنین برای نوشتن کد‌ها مجبور نبودم کد را کپی و در برنامه تک پیست کنم و تنها با فراخوانی کردن فایل مورد نظر آن را فراخوانی کردم و در برنامه قرار دادم . 
\lr{ open cmd(command prompt) then type "texdoc listings"}

\newpage 
\begin{latin}
\lstinputlisting[basicstyle=\ttfamily % inja khatti ke bahash barnameh zade mishe ro khastam ttfamily bashe ke in baes mishe eine khode compiler darad 
 , frame=trBL% forme table ro moshakhas kardam 
  , flexiblecolumns=true% in khodesh faseleye beine sotoonharo moshakhas mikone va flexible mikone 
 ]{HW71.cpp}
 
 the second way 
 \begin{lstlisting} 
 for(t=0; t<T; t++)
{
	for(i=2; i <N-1; i++)
		for(j=2; j < n-1; j++)
			S_1(t, i, j):B[i][j] = 
				     (A[i][j] + 
						A[i][j-1]+
						A[i][j+1] + 
						A[i-1][j] + 
						A[i+1][j])/5;
	for(i =2; i <N-1; i++)
		for(j=2; j<N-1; j++)
			S_2(t, i, j):A[i][j] = B[i][j];
}
 \end{lstlisting}
 \end{latin}
 % be soorate kolli do joor mishe code gozasht : 
 % 1- estefade az dastoor : \begin{lstlisting} Code \end{lstlisting} ke code ro mostaghiman mizari too barname 
 % 2- estefadeh az \lstinputlisting[options]{filename} ke dar bakhshe options vijegihayi ke mikhay dashte bashe va dar file name esme filet ba passد . 

\end{document}