Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.9 kB
7
Indexable
Never
% !TXS template
\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath}
%\usepackage{unicode-math}
\usepackage[a4paper]{geometry}
\usepackage{pifont}
\usepackage{amsfonts}
\usepackage{lmodern}
\usepackage{babel}
\usepackage{stmaryrd}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}

%\usepackage{minted}

%\usepackage{titlesec}
\usepackage{lipsum}
\author{Théo DIEDA}
\date{2021 - 2022}
\title{Cours d'Informatique PCSI}

\pagestyle{fancy}
\renewcommand\headrulewidth{1pt}
\fancyhead[L]{Théo DIEDA}
\fancyhead[R]{PCSI 1 - Lycée Kléber}
\fancyfoot[C]{Page \thepage}
\fancyfoot[R]{2021/2022}



\usepackage{xcolor}
\definecolor{rouge}{HTML}{ff0000}
\definecolor{bleu}{HTML}{0000ff}
\definecolor{vert}{HTML}{00ff00}

\usepackage{titlesec}
% ----- CUT HERE ----- %
%  Supplement to titlesec providing the \addtotitleformat
%+ command for appending instead of overwriting the current style.
\makeatletter
\newcommand*\@secondofsix[6]{#2}
\newcommand{\addtotitleformat}{%
    \@ifstar{\addtotitleformat@star}{\addtotitleformat@nostar}}
\newcommand\addtotitleformat@nostar[2]{%
    \PackageError{titlesec}{non starred form of \string\addtotitleformat\space not supported}{}}
\newcommand\addtotitleformat@star[2]{%
    \edef\@currentsection@font{%
        \unexpanded\expandafter\expandafter\expandafter
            {\expandafter\expandafter\expandafter\@secondofsix \csname ttlf@\expandafter\@gobble\string#1\endcsname}}%
    \titleformat*{#1}{\@currentsection@font#2}%
}
\makeatother
% ----- CUT HERE ----- %



\renewcommand{\thesection}{\color{rouge}\huge\Roman{section})}
\addtotitleformat*{\section}{\color{rouge}\huge}
\renewcommand{\thesubsection}{\color{bleu}\Large\arabic{subsection})}
\addtotitleformat*{\subsection}{\color{bleu}\Large}
\renewcommand{\thesubsubsection}{\color{vert}\large\alph{subsubsection})}
\addtotitleformat*{\subsubsection}{\color{vert}\large}


\setlength{\parindent}{0pt}
\renewcommand{\Frlabelitemi}{\textbullet}

%%%
%\renewcommand{\thesection}{\Roman{section}/}
%\renewcommand{\thesubsection}{\arabic{subsection}/}
%\renewcommand{\thesubsubsection}{\alph{subsubsection})}
%%%

\usepackage{listings}
%%%------------------------
%New colors defined below
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

%Code listing style named "mystyle"
\lstdefinestyle{mystyle}{
  backgroundcolor=\color{backcolour},   commentstyle=\color{codegreen},
  keywordstyle=\color{magenta},
  numberstyle=\tiny\color{codegray},
  stringstyle=\color{codepurple},
  basicstyle=\ttfamily\footnotesize,
  breakatwhitespace=false,         
  breaklines=true,                 
  captionpos=b,                    
  keepspaces=true,                 
  numbers=left,                    
  numbersep=5pt,                  
  showspaces=false,                
  showstringspaces=false,
  showtabs=false,                  
  tabsize=2
}

%"mystyle" code listing set
\lstset{style=mystyle}
%%%-------------------------













\begin{document}
	%\tableofcontents
	\newpage 


Exemple :
%\begin{minted}{Python}
\begin{lstlisting}[language=Python]
def fusion(L1,L2):
	"(liste,liste)->list
	'L1' et 'L2' sont 2 listes triees d'elements comparables.
	Renvoie 'L' une liste triee, fusion de 'L1' et 'L2'"
	#Precondition : L1 et L2 tries
	assert(est_triee(L1), "L1 non triee !")
	assert(est_triee(L2), "L2 non triee !")
	
	L=[] #Liste d'arrivee
	i1, i2, n1, n2 = 0, 0, len(L1), len(L2) #Initialisation
	
	for i in range(n1+n2):
		if i1==n1 or (i2 < n2 and L1[i1] > L2[i2]):
			candidat = L2[i2]
			i2 += 1
		else:
			candidat = L1[i1]
			i1 += 1
		L.append(candidat) 
		#L est triee et de bonne taille
		assert(est_triee(L), "L non triee dans la boucle")
		asseert(len(L)==i+1, "L pas de bonne taille")
	return L
\end{lstlisting}
%\end{minted}

\end{document}