Skip to content

Instantly share code, notes, and snippets.

@pveyes
Last active November 8, 2016 16:47
Show Gist options
  • Save pveyes/d8b0c7b99fd93e0c9d46d1ed3ccd4f7a to your computer and use it in GitHub Desktop.
Save pveyes/d8b0c7b99fd93e0c9d46d1ed3ccd4f7a to your computer and use it in GitHub Desktop.
document.write('<link rel="stylesheet" href="https://assets-cdn.github.com/assets/gist-embed-9ec60d02ee0eb30530c9c2d12055b82db581fbb13b64b807fd63df9cd276d21b.css">')
document.write('<div id=\"gist8380521\" class=\"gist\">\n <div class=\"gist-file\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-fb-arithmetic-c\" class=\"file\">\n \n\n <div itemprop=\"text\" class=\"blob-wrapper data type-c\">\n <table class=\"highlight tab-size js-file-line-container\" data-tab-size=\"8\">\n <tr>\n <td id=\"file-fb-arithmetic-c-L1\" class=\"blob-num js-line-number\" data-line-number=\"1\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC1\" class=\"blob-code blob-code-inner js-file-line\">#<span class=\"pl-k\">include<\/span> <span class=\"pl-s\"><span class=\"pl-pds\">&lt;<\/span>stdio.h<span class=\"pl-pds\">&gt;<\/span><\/span><\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L2\" class=\"blob-num js-line-number\" data-line-number=\"2\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC2\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L3\" class=\"blob-num js-line-number\" data-line-number=\"3\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC3\" class=\"blob-code blob-code-inner js-file-line\"><span class=\"pl-k\">int<\/span> <span class=\"pl-en\">main<\/span>() {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L4\" class=\"blob-num js-line-number\" data-line-number=\"4\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC4\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">int<\/span> input, val;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L5\" class=\"blob-num js-line-number\" data-line-number=\"5\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC5\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">int<\/span> init, delta = <span class=\"pl-c1\">0<\/span>, newdelta;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L6\" class=\"blob-num js-line-number\" data-line-number=\"6\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC6\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">int<\/span> i;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L7\" class=\"blob-num js-line-number\" data-line-number=\"7\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC7\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L8\" class=\"blob-num js-line-number\" data-line-number=\"8\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC8\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-c1\">scanf<\/span>(<span class=\"pl-s\"><span class=\"pl-pds\">&quot;<\/span><span class=\"pl-c1\">%d<\/span><span class=\"pl-cce\">\\n<\/span><span class=\"pl-pds\">&quot;<\/span><\/span>, &amp;input);<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L9\" class=\"blob-num js-line-number\" data-line-number=\"9\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC9\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-c1\">scanf<\/span>(<span class=\"pl-s\"><span class=\"pl-pds\">&quot;<\/span><span class=\"pl-c1\">%d<\/span> <span class=\"pl-pds\">&quot;<\/span><\/span>, &amp;init);<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L10\" class=\"blob-num js-line-number\" data-line-number=\"10\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC10\" class=\"blob-code blob-code-inner js-file-line\"> <\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L11\" class=\"blob-num js-line-number\" data-line-number=\"11\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC11\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">for<\/span> (i = <span class=\"pl-c1\">1<\/span>; i &lt; input; i++) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L12\" class=\"blob-num js-line-number\" data-line-number=\"12\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC12\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-c1\">scanf<\/span>(<span class=\"pl-s\"><span class=\"pl-pds\">&quot;<\/span><span class=\"pl-c1\">%d<\/span> <span class=\"pl-pds\">&quot;<\/span><\/span>, &amp;val);<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L13\" class=\"blob-num js-line-number\" data-line-number=\"13\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC13\" class=\"blob-code blob-code-inner js-file-line\"> newdelta = val - init;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L14\" class=\"blob-num js-line-number\" data-line-number=\"14\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC14\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L15\" class=\"blob-num js-line-number\" data-line-number=\"15\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC15\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">if<\/span> (newdelta == <span class=\"pl-c1\">2<\/span> * delta) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L16\" class=\"blob-num js-line-number\" data-line-number=\"16\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC16\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-c\">// skip on current loop<\/span><\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L17\" class=\"blob-num js-line-number\" data-line-number=\"17\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC17\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-c1\">printf<\/span>(<span class=\"pl-s\"><span class=\"pl-pds\">&quot;<\/span><span class=\"pl-c1\">%d<\/span><span class=\"pl-cce\">\\n<\/span><span class=\"pl-pds\">&quot;<\/span><\/span>, val - delta);<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L18\" class=\"blob-num js-line-number\" data-line-number=\"18\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC18\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">break<\/span>;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L19\" class=\"blob-num js-line-number\" data-line-number=\"19\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC19\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L20\" class=\"blob-num js-line-number\" data-line-number=\"20\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC20\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">else<\/span> <span class=\"pl-k\">if<\/span> (delta == <span class=\"pl-c1\">2<\/span> * newdelta) {<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L21\" class=\"blob-num js-line-number\" data-line-number=\"21\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC21\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-c\">// skip on previous loop<\/span><\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L22\" class=\"blob-num js-line-number\" data-line-number=\"22\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC22\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-c1\">printf<\/span>(<span class=\"pl-s\"><span class=\"pl-pds\">&quot;<\/span><span class=\"pl-c1\">%d<\/span><span class=\"pl-cce\">\\n<\/span><span class=\"pl-pds\">&quot;<\/span><\/span>, init - newdelta);<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L23\" class=\"blob-num js-line-number\" data-line-number=\"23\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC23\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">break<\/span>;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L24\" class=\"blob-num js-line-number\" data-line-number=\"24\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC24\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L25\" class=\"blob-num js-line-number\" data-line-number=\"25\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC25\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L26\" class=\"blob-num js-line-number\" data-line-number=\"26\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC26\" class=\"blob-code blob-code-inner js-file-line\"> delta = newdelta;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L27\" class=\"blob-num js-line-number\" data-line-number=\"27\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC27\" class=\"blob-code blob-code-inner js-file-line\"> init = val;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L28\" class=\"blob-num js-line-number\" data-line-number=\"28\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC28\" class=\"blob-code blob-code-inner js-file-line\"> }<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L29\" class=\"blob-num js-line-number\" data-line-number=\"29\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC29\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L30\" class=\"blob-num js-line-number\" data-line-number=\"30\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC30\" class=\"blob-code blob-code-inner js-file-line\"> <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">0<\/span>;<\/td>\n <\/tr>\n <tr>\n <td id=\"file-fb-arithmetic-c-L31\" class=\"blob-num js-line-number\" data-line-number=\"31\"><\/td>\n <td id=\"file-fb-arithmetic-c-LC31\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n <\/tr>\n<\/table>\n\n <\/div>\n\n <\/div>\n \n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/pveyes/8380521/raw/558ec17e8fa448e84409c04f32956153379bb265/fb-arithmetic.c\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/pveyes/8380521#file-fb-arithmetic-c\">fb-arithmetic.c<\/a>\n hosted with &#10084; by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment