\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{Almog1339} \pdfinfo{ /Title (c.pdf) /Creator (Cheatography) /Author (Almog1339) /Subject (C 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}{78C1CF} \definecolor{LightBackground}{HTML}{EEF7F9} \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{C Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Almog1339} via \textcolor{DarkBackground}{\uline{cheatography.com/84407/cs/19968/}}} \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}Almog1339 \\ \uline{cheatography.com/almog1339} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 1st July, 2019.\\ Updated 1st July, 2019.\\ 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}{for loops}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#include \textless{}stdio.h\textgreater{} \newline \newline int main()\{ \newline int i; \newline \newline for( i =0 ; i \textgreater{}= /\textless{}= something ; i++/i-{}-)\{ \newline do somthing \newline \} \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{עבור לולאות פור, תמיד בהתחלת הלולאה נגדיר משתנה וכמה הוא שווה, לאחר מכן נגדיר את תנאי העצירה, ולבסוף נרשום אם אנו רוצים להגדיר את ערכו של האיבר או להורידו} \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}{while}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#include \textless{}stdio.h\textgreater{} \newline \newline int main()\{ \newline int a=1; \newline \newline while(a)\{ \newline do someting; \newline a-{}-; \newline \} \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{בלולאה זו או מגדירים את המשתנה שלו מחוץ ללולאה, ואנו רצים כל עוד שהמשתנה שלנו שונה מ-0 \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}{do while}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\#include \textless{}stdio.h\textgreater{} \newline % Row Count 1 (+ 1) int main()\{ \newline % Row Count 2 (+ 1) int a=3; \newline % Row Count 3 (+ 1) do\{ \newline % Row Count 4 (+ 1) printf("Hi"); \newline % Row Count 5 (+ 1) a-{}-; \newline % Row Count 6 (+ 1) \} \newline % Row Count 7 (+ 1) while(a); \newline % Row Count 8 (+ 1) \}% Row Count 9 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{בלולאה זו אנו מגדירם את המשתנה שלו מחוץ לפונקציה, את השינוי של הערך אנו נעשה בתוך הלולאה. \newline ההבל המרכזי בין לולאה זה לבין לולאת while \newline הוא שבלולאה זו אנו נרוץ פעם אחת לפחות \newline בדוגמה זו אנו נדפיס למסך היי 3 פעמים} \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}{program}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#include \textless{}stdio.h\textgreater{} \newline \newline int/void func(int a/void); \newline \newline int/void main()\{ \newline int a,b; \newline b = func(a); \newline \} \newline \newline int/void func(int k)\{ \newline do someting; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{תמיד יש צורך להכיל את הפונקציית ספרייה עבור קלט ופלט \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}{פונקציות}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#include \textless{}stdio.h\textgreater{} \newline \newline int func(int z); \newline \newline int main()\{ \newline int x=4,y; \newline y = func(int y); \newline \} \newline \newline int func(int z)\{ \newline do somting...; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{בפונקציות יש להכריז עליהם בתחילת התוכנית \newline את התשובת שהתוכנית מחזירה אנו מציבים ל y} \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}{ניתוח תוכנית}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{כאשר אנו מנתחים תוכית מומלץ מאוד לעבוד עם טבלת מעקב \newline % Row Count 2 (+ 2) שבה אנו נרשום את כל הפרמטרים שבהם אנו נתקלים ונעבור שורה שורה ונרשום לעצמנו מה אותו קטע קוד עושה% Row Count 6 (+ 4) } \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}{מספר ראשוני}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{מספר ראשוני הוא מספר שמתחלק רק בעצמו וב-1% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.824 cm} x{1.748 cm} x{4.028 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{פונקציות שימושיות}} \tn % Row 0 \SetRowColor{LightBackground} from & function name & what it do \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{\#include} \textless{}stdio.h\textgreater{} & \seqsplit{printf("\%d"},num); & מדפיס למסך את המשתנה \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} & \seqsplit{scanf("\%d"},\&num); & קולט לתוך המשתנה מספר מהמשתמש \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{\#include} \textless{}math.h\textgreater{} & pow(num,2); & מעלה את נאם בחזקת 2 \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} & \seqsplit{sqrt(double(x));} & שורש עבור איקס \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{משתנה גלובלי}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{כאשר קיים בתוכנית משתנה מרכזי הנדרש ברוב הפונקציות מומלץ להגדירו במשתנה \newline % Row Count 3 (+ 3) גלובלי על ידי הגדרתו בראשית התוכנית בחוץ לפונקציות \newline % Row Count 5 (+ 2) משמעות הדבר היא שמשתנה זה מוכר וניתן לשימוש על ידי כל אחת מפונקציות התוכנית. \newline % Row Count 8 (+ 3) במידה ולא אותחל ערכו ההתחלתי יהיה 0 ולא זבלי. \newline % Row Count 10 (+ 2) רצוי להמעיט בהגדרות גלובליות על מנת לא להעמיס את כל המשתנים בראשית התוכנית. \newline % Row Count 13 (+ 3) כאשר משתנה הוא גלובלי אין צורך לשלוח אותו או להחזירו בין הפונקציות כי כולן מכירות בו.% Row Count 17 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.712 cm} p{1.444 cm} p{1.444 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{טבלאות מעקב}} \tn % Row 0 \SetRowColor{LightBackground} מחזור & num & max \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 1 & 5 & 5 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 2 & 2 & 5 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 3 & 8 & 5 \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 4 & 6 & 8 \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} 5 & 0 & 8 \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{\#include \textless{}stdio.h\textgreater{} \newline \newline int main()\{ \newline int num,max; \newline scanf("\%d",\&num); \newline max=num; \newline while(num)\{ \newline if (num \textgreater{} num) \newline max=num; \newline scanf("\%d",\&num); \newline \} \newline return num; \newline \} \newline //5,2,8,6,0} \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}{לולאות מקוננות}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{static void Main(string{[}{]} args) \newline \{ \newline for (int y = 1; y \textless{}= 10; y++) \newline \{ \newline for (int x = 1; x \textless{}= 10; x++) \newline \{ \newline Console.Write("\{0,4\}", x * y); \newline \} \newline Console.WriteLine(); \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}{מציאת מספר ראשוני}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#include\textless{}stdio.h\textgreater{} \newline \newline int check\_prime(int a); \newline \newline main() \newline \{ \newline int n, result; \newline \newline printf("Enter an integer to check whether it is prime or not.\textbackslash{}n"); \newline scanf("\%d",\&n); \newline \newline result = check\_prime(n); \newline \newline if ( result == 1 ) \newline printf("\%d is prime.\textbackslash{}n", n); \newline else \newline printf("\%d isn't prime.\textbackslash{}n", n); \newline \newline return 0; \newline \} \newline \newline int check\_prime(int a) \newline \{ \newline int c; \newline \newline for ( c = 2 ; c \textless{}= a - 1 ; c++ ) \newline \{ \newline if ( a\%c == 0 ) \newline return 0; \newline \} \newline if ( c == a ) \newline return 1; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}