\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{{[}deleted{]}} \pdfinfo{ /Title (exemples.pdf) /Creator (Cheatography) /Author ({[}deleted{]}) /Subject (Exemples Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{8456A3} \definecolor{LightBackground}{HTML}{F7F4F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Exemples Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{{[}deleted{]}} via \textcolor{DarkBackground}{\uline{cheatography.com/19776/cs/2736/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}{[}deleted{]} \\ \uline{cheatography.com/deleted-19776} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 24th October, 2014.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Boucles 2}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{final double TAUX\_TPS = 0.06; \newline final double TAUX\_TVQ = 0.075; \newline double montant; \newline double tps = 0; \newline double tvq = 0; \newline char reponse; \newline System.out.print ( "Veuillez entrer un montant (0 pour terminer) : " ); \newline montant = Clavier.lireDouble(); \newline while ( montant != 0 ) \{ \newline System.out.print ( "La tps s'applique-t-elle ? " ); \newline reponse = Clavier.lireCharLn(); \newline if ( reponse == 'O' || reponse == 'o' ) \{ \newline tps = montant {\emph{ TAUX\_TPS; \newline System.out.println ( "La tps est : " + dec2.format ( tps ) ); \newline \} \newline System.out.print ( "La tvq s'applique-t-elle ? " ); \newline reponse = Clavier.lireCharLn(); \newline if ( reponse == 'O' || reponse == 'o' ) \{ \newline tvq = ( montant + tps ) }} TAUX\_TVQ; \newline System.out.println ( "La tps est : " + dec2.format ( tvq ) ); \newline \} \newline System.out.println ( "Le total est : " + dec2.format ( montant + \newline tps + tvq ) ); \newline \seqsplit{System.out.print("Veuillez} entrer un montant (0 pour terminer):"); \newline montant = Clavier.lireDouble(); \newline \}
} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{TPS/TVQ de façon à permettre de traiter \newline plusieurs montants. Si le montant entré est égal à 0, le programme doit se terminer.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Boucles 3}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{int n; \newline int impair; \newline System.out.print ( "Veuillez entrer un nombre positif : " ); \newline n = Clavier.lireInt(); \newline while ( n \textless{}= 0 ) \{ \newline System.out.println ( "{\emph{*}} Nombre invalide." ); \newline System.out.print ( "Veuillez entrer un nombre positif : " ); \newline n = Clavier.lireInt(); \newline \} \newline impair = 1; \newline for ( int i = 0; i \textless{} n; i++ ) \{ \newline System.out.print ( impair + " " ); \newline impair = impair + 2; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{affiche les n premiers nombres impairs positifs} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Boucles 1}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{int annee; \newline System.out.println ( "Veuillez entrer une annee (positive) : " ); \newline annee = Clavier.lireInt(); \newline while ( annee \textless{}= 0 ) \{ \newline System.out.println ( "* Annee non valide." ); \newline System.out.print ( "Veuillez entrer une annee (positive) : " ); \newline annee = Clavier.lireInt(); \newline \} \newline if(((annee \% 4 == 0) \&\& (annee \% 100 != 0)) || (annee \% 400 == 0)) \{ \newline System.out.println ( "Annee bissextile." ); \newline \} else \{ \newline System.out.println ( "Annee non bissextile." ); \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{On vous demande d'ajouter une boucle de validation de l'année à l'exercice portant sur les années bissextiles.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Methodes 1}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{public static double reelValide(String msgInvite, String msgErreur, double min, double max) \{ \newline double valeurSaisie; \newline System.out.print("\textbackslash{}n" + msgInvite); \newline valeurSaisie = Clavier.lireDouble(); \newline while (valeurSaisie \textless{} min || valeurSaisie \textgreater{} max)\{ \newline System.out.println("\textbackslash{}n" + msgErreur); \newline \seqsplit{System.out.print(msgInvite);} \newline valeurSaisie = Clavier.lireDouble(); \newline \} \newline return valeurSaisie; \newline \} \newline public static double alcoolemie (double qte, double taux, double poids) \{ \newline return ((qte {\emph{ taux) / (poids }} 0.4)); \newline \} \newline public static void afficherAlcoolemie (double alcoolemie) \{ \newline System.out.println("\textbackslash{}nVotre taux d'alcool dans le sang est de " + \newline alcoolemie); \newline if (alcoolemie \textgreater{}= 0.08)\{ \newline System.out.println("\textbackslash{}n\textbackslash{}nAttention! \newline Votre taux d'alcool dans le sang dépasse"+"\textbackslash{}nla limite \newline sécuritaire de 0.08 . »); \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{int depart; \newline 
int pas; \newline 
int limite;
 \newline int somme; \newline 
int nbPas;
 \newline boolean pasEstPositif; \newline System.out.print ( messInviteDepart ); \newline depart = Clavier.lireInt(); \newline System.out.print ( messInvitePas ); \newline pas = Clavier.lireInt(); \newline 
while ( pas == 0 ) \{
 \newline System.out.println ( messErreurPas );
 \newline System.out.print ( messInvitePas );
 \newline pas = Clavier.lireInt(); \newline 
\}
 \newline pasEstPositif = pas \textgreater{} 0;
 \newline System.out.print ( messInviteLimite );
 \newline limite = Clavier.lireInt();
 \newline while ( ( pasEstPositif \&\& limite \textless{}= depart ) || ( !pasEstPositif \&\& limite \textgreater{}= depart) ) \{ 
 \newline if ( pasEstPositif ) \{
 \newline System.out.println (messErreurLimiteSup); \newline \}else\{
 \newline System.out.println (messErreurLimiteInf); \newline \}
 \newline System.out.print ( messInviteLimite ); \newline limite = Clavier.lireInt();
 \newline \} \newline 
somme = depart;
 \newline nbPas = -1; \newline 
while ( pasEstPositif \&\& somme \textless{}= limite || !pasEstPositif \&\& somme \textgreater{}= limite ) \{
 \newline somme = somme + pas;
 \newline nbPas++; \newline 
\} \newline 
somme = somme - pas;
 \newline System.out.println ( "La somme est " + somme + " et le nombre de pas est " + nbPas );} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}