\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{phon} \pdfinfo{ /Title (hallo-2.pdf) /Creator (Cheatography) /Author (phon) /Subject (Hallo\#2 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}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \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{Hallo\#2 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{phon} via \textcolor{DarkBackground}{\uline{cheatography.com/25871/cs/18254/}}} \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}phon \\ \uline{cheatography.com/phon} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 13th December, 2018.\\ Updated 13th December, 2018.\\ 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}{Extralab\#9}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#include \textless{}stdio.h\textgreater{} \newline int main()\{ \newline int n; \newline printf("enter n: "); \newline scanf("\%d",\&n); \newline int array1{[}n{]}{[}n{]},array2{[}n{]}{[}n{]}; \newline for (int i = 0;i \textless{} n;i++)\{ \newline for (int j = 0;j \textless{} n;j++)\{ \newline printf("Enter element for array1{[}\%d{]}{[}\%d{]}: ", i+1,j+1); \newline scanf("\%d", \&array1{[}i{]}{[}j{]}); \newline \} \newline \} \newline printf("\textbackslash{}n"); \newline for (int i = 0;i \textless{} n;i++)\{ \newline for (int j = 0;j \textless{} n;j++)\{ \newline printf("Enter element for array2{[}\%d{]}{[}\%d{]}: ", i+1,j+1); \newline scanf("\%d", \&array2{[}i{]}{[}j{]}); \newline \} \newline \} \newline int count = 0; \newline for (int i = 0;i \textless{} n;i++)\{ \newline for (int j = 0;j \textless{} n;j++)\{ \newline if (array1{[}i{]}{[}j{]} == array2{[}i{]}{[}j{]})\{ \newline count++; \newline \} \newline \} \newline \} \newline for (int i = 0;i \textless{} n;i++)\{ \newline for (int j = 0;j \textless{} n;j++)\{ \newline printf("\%d ",array1{[}i{]}{[}j{]}); \newline \} \newline printf("\textbackslash{}n"); \newline \} \newline printf("\textbackslash{}n"); \newline for (int i = 0;i \textless{} n;i++)\{ \newline for (int j = 0;j \textless{} n;j++)\{ \newline printf("\%d ",array2{[}i{]}{[}j{]}); \newline \} \newline printf("\textbackslash{}n"); \newline \} \newline if (count == n {\emph{ n)\{ \newline printf("Both are equal\textbackslash{}n"); \newline \} \newline else\{ \newline printf("Both are not equal\textbackslash{}n"); \newline \} \newline printf("Multiplication of metrices is: \textbackslash{}n"); \newline int ans\_array{[}n{]}{[}n{]}; \newline int sum = 0; \newline for (int i = 0;i \textless{} n;i++)\{ \newline for (int j = 0;j \textless{} n;j++)\{ \newline for (int k = 0;k \textless{} n;k++)\{ \newline sum += array1{[}i{]}{[}k{]}}}array2{[}k{]}{[}j{]}; \newline \} \newline ans\_array{[}i{]}{[}j{]} = sum; \newline sum = 0; \newline \} \newline \} \newline for (int i = 0;i \textless{} n;i++)\{ \newline for (int j = 0;j \textless{} n;j++)\{ \newline printf("\%d ",ans\_array{[}i{]}{[}j{]}); \newline \} \newline printf("\textbackslash{}n"); \newline \} \newline int sum\_metrix = 0; \newline for (int i = 0;i \textless{} n;i++)\{ \newline for (int j = 0;j \textless{} n;j++)\{ \newline if (i==j)\{ \newline sum\_metrix += ans\_array{[}i{]}{[}j{]}; \newline \} \newline \} \newline \} \newline printf("Sum of the diagonal is \%d",sum\_metrix); \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}{Extralab\#10}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#include \textless{}stdio.h\textgreater{} \newline \#include \textless{}string.h\textgreater{} \newline int main()\{ \newline char sentence1{[}255{]},sentence2{[}255{]}; \newline printf("Input sentence1: "); \newline gets(sentence1); \newline printf("Input sentence2: "); \newline gets(sentence2); \newline printf("String is longer than string2?"); \newline fputs(strlen(sentence1) \textgreater{} strlen(sentence2) ? " true" : " false",stdout); \newline printf("\textbackslash{}nString has more vowal than string2?"); \newline int count\_string1 = 0; \newline int c = 0; \newline while(sentence1{[}c{]} != '\textbackslash{}0')\{ \newline if (sentence1{[}c{]} == 'a' || sentence1{[}c{]} == 'A' \newline || sentence1{[}c{]} == 'e' || sentence1{[}c{]} == 'E' \newline || sentence1{[}c{]} == 'i' || sentence1{[}c{]} == 'I' \newline || sentence1{[}c{]} == 'o' || sentence1{[}c{]} == 'O' \newline || sentence1{[}c{]} == 'u' || sentence1{[}c{]} == 'U')\{ \newline count\_string1++; \newline \} \newline c++; \newline \} \newline int count\_string2 = 0; \newline int d = 0; \newline while(sentence1{[}d{]} != '\textbackslash{}0')\{ \newline if (sentence1{[}d{]} == 'a' || sentence1{[}d{]} == 'A' \newline || sentence1{[}d{]} == 'e' || sentence1{[}d{]} == 'E' \newline || sentence1{[}d{]} == 'i' || sentence1{[}d{]} == 'I' \newline || sentence1{[}d{]} == 'o' || sentence1{[}d{]} == 'O' \newline || sentence1{[}d{]} == 'u' || sentence1{[}d{]} == 'U')\{ \newline count\_string2++; \newline \} \newline d++; \newline \} \newline fputs(count\_string1 \textgreater{} count\_string2 ? " true" : " false", stdout); \newline \newline int first{[}26{]} = \{0\}, second{[}26{]} = \{0\}; \newline int e = 0; \newline // Calculating frequency of characters of first string \newline while (sentence1{[}e{]} != '\textbackslash{}0')\{ \newline first{[}sentence1{[}e{]} - 'a'{]}++; \newline e++; \newline \} \newline int f = 0; \newline while (sentence1{[}f{]} != '\textbackslash{}0')\{ \newline first{[}sentence1{[}f{]} - 'a'{]}++; \newline f++; \newline \} \newline // Comparing frequency of characters \newline int count\_similar = 0; \newline for (int c = 0;c \textless{} 26;c++)\{ \newline for (int d = 0;d \textless{} 26;d++)\{ \newline if (first{[}c{]} == second{[}d{]})\{ \newline count\_similar++; \newline \} \newline \} \newline \} \newline if (count\_similar != 0)\{ \newline printf("\textbackslash{}nThe strings are anagrams.\textbackslash{}n"); \newline \} \newline else\{ \newline printf("\textbackslash{}nThe strings are not anagrams.\textbackslash{}n"); \newline \} \newline return 0; \newline \} \newline \newline Input sentence1: cineman \newline Input sentence2: iceman \newline String is longer than string2? true \newline String has more vowal than string2? false \newline The strings are anagrams.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}