#include <stdio.h>
int main() {
return 0;
}
#include <stdio.h>
int main() {
float x,y;
scanf("%f", &x);
scanf("%f", &y);
printf("%f\n%f\n%f\n%f", x+y, x-y, x*y, x/y);
return 0;
}
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
printf("area: %f",3.14/4*a*b);
return 0;
}
#include <stdio.h>
int main() {
int x{if(!e||!e.classList.contains("mod-collapsible"))return;let o=e.querySelector(".tree-item-children");t?e.classList.add("is-collapsed"):e.classList.remove("is-collapsed"),n.push(o)})),t?o?a(n,100):n.forEach((async e=>e.style.display="none")):o?d(n,100):n.forEach((async e=>e.style.removeProperty("display")))}function i(e){let t=e.firstChild,o=!1;for(;null!=t&&(o=!!t&&/[Hh][1-6]/g.test(t.tagName),!o);)t=t.nextElementSibling;return t}function l(e){let t=e.previousElementSibling,o=!1;for(;null!=t;){let e=i(t);if(o=!!e&&/[Hh][1-6]/g.test(e.tagName),o)break;t=t.previousElementSibling}return t}function r(e,t,o=!0){if("DIV"!=e.tagName||!i(e))return void console.error("setHeaderOpen() must be called with a header div");t&&(e.classList.remove("is-collapsed"),e.style.display=""),t||e.classList.add("is-collapsed");let n=i(e),s=[],a=e.nextElementSibling;for(;null!=a;){let e=i(a);if(e){if(e.tagName<=n.tagName)break;s.push(a)}a.style.display=t?"":"none",a=a.nextElementSibling}if(t&&(s.forEach((function(e){e.classList.contains("is-collapsed")&&r(e,!1)})),o)){let t=l(e);for(;null!=t;){if(i(t).tagName{e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.offsetHeight,e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,window.setTimeout((async()=>{e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")}),t)},a=(e,t=500)=>{e.forEach((async e=>{e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.offsetHeight,e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0})),window.setTimeout((async()=>{e.forEach((async e=>{e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")}))}),t)},c=(e,t=500)=>{e.style.removeProperty("display");let o=window.getComputedStyle(e).display;"none"===o&&(o="block"),e.style.display=o;let n=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.offsetHeight,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=n+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),window.setTimeout((async()=>{e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")}),t)},d=(e,t=500)=>{e.forEach((async e=>{e.style.removeProperty("display");let o=window.getComputedStyle(e).display;"none"===o&&(o="block"),e.style.display=o;let n=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.offsetHeight,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=n+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom")})),window.setTimeout((async()=>{e.forEach((async e=>{e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")}))}),t)};var y=(e,t=500)=>"none"===window.getComputedStyle(e).display?c(e,t):s(e,t);async function u(o,n=!0,i=!0){let l;console.log("Loading document: "+o),m(o,i,n);try{l=await fetch(o)}catch(e){return console.log("Cannot use fetch API (likely due to CORS), just loading the page normally."),void window.location.assign(o)}let r=document.implementation.createHTMLDocument();if(l.ok){let e=(await l.text()).replaceAll("","").replaceAll("","").replaceAll("","");r.documentElement.innerHTML=e,document.querySelector(".document-container").innerHTML=r.querySelector(".document-container").innerHTML,document.querySelector(".outline-tree").innerHTML=r.querySelector(".outline-tree").innerHTML;let t=o.split("#"),n=(t[0],t.length>1?t[1]:null);n&&document.getElementById(n).scrollIntoView(),f(r),b(document.querySelector(".document-container")),b(document.querySelector(".outline-tree")),document.title=r.title}else{document.querySelector(".markdown-preview-view").innerHTML="\n\t\t\n\t\t\t\n\t\t\t\tPage Not Found
\n\t\t\t \n\t\t\n\t\t",document.querySelector(".outline-tree").innerHTML="",console.log("Page not found: "+e()+o);let n=function(e=window.location.pathname){let o=t(e).split("/"),n="";for(let e=0;e .tree-item-contents > .tree-item-link"));for(let t of r)if(t.getAttribute("href")!=e);else{let e=t.parentElement.parentElement;for(e.classList.add("mod-active"),l=e;e.hasAttribute("data-depth");)o(e,!1,!1),e=e.parentElement.parentElement}if(t&&l?.scrollIntoView({block:"center",inline:"nearest"}),"undefined"!=typeof nodes&&window.renderWorker){let e=nodes?.paths.findIndex((function(e){return e.endsWith(i)}))??-1;e>=0&&(window.renderWorker.activeNode=e)}n&&"file:"!=window.location.protocol&&window.history.pushState({path:i},"",i)}function p(e){const t=Array.from(e.querySelectorAll(".tree-container.file-tree .tree-item"));e.querySelectorAll(".tree-item-contents > .collapse-icon").forEach((function(e){e.addEventListener("click",(function(){var t;(t=e.parentElement.parentElement)&&o(t,!t.classList.contains("is-collapsed"))}))}));let i=e.querySelector(".tree-container.file-tree .collapse-tree-button");i&&i.addEventListener("click",(async function(){let e=i.classList.contains("is-collapsed");n(t,!e,t.length<100),i.classList.toggle("is-collapsed"),i.querySelector("iconify-icon").setAttribute("icon",e?"ph:arrows-out-line-horizontal-bold":"ph:arrows-in-line-horizontal-bold")}));let l=e.querySelector(".tree-container.outline-tree .collapse-tree-button");l&&l.addEventListener("click",(async function(){let e=l.classList.contains("is-collapsed"),t=Array.from(l.parentElement.parentElement.querySelectorAll(".tree-item"));n(t,!e,t.length<100),l.classList.toggle("is-collapsed"),l.querySelector("iconify-icon").setAttribute("icon",e?"ph:arrows-out-line-horizontal-bold":"ph:arrows-in-line-horizontal-bold")})),e.querySelectorAll(".tree-container .tree-item").forEach((function(e){e.classList.contains("is-collapsed")&&o(e,!0,!1)})),e.querySelectorAll(".tree-container > .tree-header > .collapse-tree-button").forEach((function(e){e.classList.contains("is-collapsed")?e.querySelector("iconify-icon").setAttribute("icon","ph:arrows-out-line-horizontal-bold"):e.querySelector("iconify-icon").setAttribute("icon","ph:arrows-in-line-horizontal-bold")}))}let h,g;function f(e){let t=e.querySelector("#root-path").getAttribute("root-path");document.querySelector("base").href=t,document.querySelector("#root-path").setAttribute("root-path",t),rootPath=t}let v=!1;function b(e){!function(e){function t(e,t=!1){let o=document.querySelector(".theme-toggle-input");if(o.checked=e,t){var n=document.body.style.transition;document.body.style.transition="none"}!o.classList.contains("is-checked")&&e?o.classList.add("is-checked"):o.classList.contains("is-checked")&&!e&&o.classList.remove("is-checked"),e?(document.body.classList.contains("theme-dark")&&document.body.classList.remove("theme-dark"),document.body.classList.contains("theme-light")||document.body.classList.add("theme-light")):(document.body.classList.contains("theme-light")&&document.body.classList.remove("theme-light"),document.body.classList.contains("theme-dark")||document.body.classList.add("theme-dark")),t&&setTimeout((function(){document.body.style.transition=n}),100),localStorage.setItem("theme_toggle",e?"true":"false")}null!=localStorage.getItem("theme_toggle")&&t("true"==localStorage.getItem("theme_toggle")),document.body.classList.contains("theme-light")?t(!0):t(!1),e.querySelector(".theme-toggle-input")?.addEventListener("change",(e=>{console.log("Theme toggle changed to: "+!("true"==localStorage.getItem("theme_toggle"))),t(!("true"==localStorage.getItem("theme_toggle")))}))}(e),function(e){e.querySelectorAll(".heading-collapse-indicator").forEach((function(e){e.addEventListener("click",(function(){var e=!this.parentElement.parentElement.classList.contains("is-collapsed");r(this.parentElement.parentElement,!e)}))})),e.querySelectorAll("a.internal-link, a.tree-item-link").forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=this.getAttribute("href");t.startsWith("#")&&(console.log("Uncollapsing header: "+t),r(document.getElementById(t.substring(1)).parentElement,!0))}))}))}(e),p(e),function(e){e.querySelectorAll(".callout.is-collapsible .callout-title").forEach((function(e){e.addEventListener("click",(function(){var t=this.parentElement;t.classList.contains("is-collapsed"),t.classList.toggle("is-collapsed"),e.querySelector(".callout-fold").classList.toggle("is-collapsed"),y(t.querySelector(".callout-content"),100)}))}))}(e),function(e){e.querySelectorAll(".task-list-item-checkbox").forEach((function(e){e.addEventListener("click",(function(){var e=this.parentElement;e.classList.toggle("is-checked"),e.setAttribute("data-task",e.classList.contains("is-checked")?"x":" ")}))})),e.querySelectorAll('.plugin-tasks-list-item input[type="checkbox"]').forEach((function(e){e.checked=e.parentElement.classList.contains("is-checked")})),e.querySelectorAll(".kanban-plugin__item.is-complete").forEach((function(e){e.querySelector('input[type="checkbox"]').checked=!0}))}(e),function(e){let t=null;e.querySelectorAll(".canvas-node-content-blocker").forEach((function(e){e.addEventListener("click",(function(){var e=this.parentElement.parentElement;e.classList.toggle("is-focused"),this.style.display="none",t&&(t.classList.remove("is-focused"),t.querySelector(".canvas-node-content-blocker").style.display=""),t=e}))}))}(e),function(e){e.querySelectorAll(".copy-code-button").forEach((function(t){t.addEventListener("click",(function(){var t=this.parentElement.querySelector("code").textContent;navigator.clipboard.writeText(t),this.textContent="Copied!",setTimeout((function(){e.querySelectorAll(".copy-code-button").forEach((function(e){e.textContent="Copy"}))}),2e3)}))}))}(e),function(e){e.querySelectorAll(".internal-link, .footnote-link, .tree-item-link").forEach((function(e){e.addEventListener("click",(function(t){let o=e.getAttribute("href");if(t.preventDefault(),o.startsWith("#")){let e=document.getElementById(o.substring(1));r(e.parentElement,!0),e.scrollIntoView()}else u(o,!0,!e.classList.contains("tree-item-link"))}))})),window.onpopstate=function(e){u(t(),!1)}}(e),function(e){function t(){let e=document.querySelector(".sidebar-right"),t=document.querySelector(".sidebar-left"),o=(e?1:0)+(t?1:0);if(0==o)return;if(h||(h=Math.max(e?.clientWidth,t?.clientWidth)),!g){let e=document.createElement("div");document.querySelector(".markdown-preview-view").appendChild(e),e.style.width="var(--line-width)",e.style.minWidth="var(--line-width)",e.style.maxWidth="var(--line-width)",g=e.clientWidth,e.remove()}let n=h*o+g/2;window.innerWidth, h, m, s;
scanf("%d", &x);
h = x / 3600;
m = (x / 60) % 60;
s = x % 60;
printf("%d:%d:%d",h,m,s);
return 0;
}
#include <stdio.h>
int main() {
int x,y, temp;
scanf("%d %d", &x, &y);
printf("x=%d y=%d\n", x, y);
temp = x;
x = y;
y = temp;
printf("x=%d y=%d\n", x, y);
return 0;
}
#include <stdio.h>function e(){return"undefined"==typeof rootPath&&f(document),new URL(window.location.href+"/../"+rootPath).pathname}function t(t=window.location.pathname){let o=e();return t.substring(o.length)}async function o(e,t,o=!0){if(!e||!e.classList.contains("mod-collapsible"))return;let n=e.querySelector(".tree-item-children");t?(e.classList.add("is-collapsed"),o?s(n,100):n.style.display="none"):(e.classList.remove("is-collapsed"),o?c(n,100):n.style.removeProperty("display"))}async function n(e,t,o=!0){let n=[];e.forEach((async e=>{if(!e||!e.classList.contains("mod-collapsible"))return;let o=e.querySelector(".tree-item-children");t?e.classList.add("is-collapsed"):e.classList.remove("is-collapsed"),n.push(o)})),t?o?a(n,100):n.forEach((async e=>e.style.display="none")):o?d(n,100):n.forEach((async e=>e.style.removeProperty("display")))}function i(e){let t=e.firstChild,o=!1;for(;null!=t&&(o=!!t&&/[Hh][1-6]/g.test(t.tagName),!o);)t=t.nextElementSibling;return t}function l(e){let t=e.previousElementSibling,o=!1;for(;null!=t;){let e=i(t);if(o=!!e&&/[Hh][1-6]/g.test(e.tagName),o)break;t=t.previousElementSibling}return t}function r(e,t,o=!0){if("DIV"!=e.tagName||!i(e))return void console.error("setHeaderOpen() must be called with a header div");t&&(e.classList.remove("is-collapsed"),e.style.display=""),t||e.classList.add("is-collapsed");let n=i(e),s=[],a=e.nextElementSibling;for(;null!=a;){let e=i(a);if(e){if(e.tagName<=n.tagName)break;s.push(a)}a.style.display=t?"":"none",a=a.nextElementSibling}if(t&&(s.forEach((function(e){e.classList.contains("is-collapsed")&&r(e,!1)})),o)){let t=l(e);for(;null!=t;){if(i(t).tagName{e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.offsetHeight,e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,window.setTimeout((async()=>{e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")}),t)},a=(e,t=500)=>{e.forEach((async e=>{e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.offsetHeight,e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0})),window.setTimeout((async()=>{e.forEach((async e=>{e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")}))}),t)},c=(e,t=500)=>{e.style.removeProperty("display");let o=window.getComputedStyle(e).display;"none"===o&&(o="block"),e.style.display=o;let n=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.offsetHeight,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=n+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),window.setTimeout((async()=>{e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")}),t)},d=(e,t=500)=>{e.forEach((async e=>{e.style.removeProperty("display");let o=window.getComputedStyle(e).display;"none"===o&&(o="block"),e.style.display=o;let n=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.offsetHeight,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=n+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom")})),window.setTimeout((async()=>{e.forEach((async e=>{e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")}))}),t)};var y=(e,t=500)=>"none"===window.getComputedStyle(e).display?c(e,t):s(e,t);async function u(o,n=!0,i=!0){let l;console.log("Loading document: "+o),m(o,i,n);try{l=await fetch(o)}catch(e){return console.log("Cannot use fetch API (likely due to CORS), just loading the page normally."),void window.location.assign(o)}let r=document.implementation.createHTMLDocument();if(l.ok){let e=(await l.text()).replaceAll("","").replaceAll("","").replaceAll("","");r.documentElement.innerHTML=e,document.querySelector(".document-container").innerHTML=r.querySelector(".document-container").innerHTML,document.querySelector(".outline-tree").innerHTML=r.querySelector(".outline-tree").innerHTML;let t=o.split("#"),n=(t[0],t.length>1?t[1]:null);n&&document.getElementById(n).scrollIntoView(),f(r),b(document.querySelector(".document-container")),b(document.querySelector(".outline-tree")),document.title=r.title}else{document.querySelector(".markdown-preview-view").innerHTML="\n\t\t\n\t\t\t\n\t\t\t\tPage Not Found
\n\t\t\t \n\t\t\n\t\t",document.querySelector(".outline-tree").innerHTML="",console.log("Page not found: "+e()+o);let n=function(e=window.location.pathname){let o=t(e).split("/"),n="";for(let e=0;e .tree-item-contents > .tree-item-link"));for(let t of r)if(t.getAttribute("href")!=e);else{let e=t.parentElement.parentElement;for(e.classList.add("mod-active"),l=e;e.hasAttribute("data-depth");)o(e,!1,!1),e=e.parentElement.parentElement}if(t&&l?.scrollIntoView({block:"center",inline:"nearest"}),"undefined"!=typeof nodes&&window.renderWorker){let e=nodes?.paths.findIndex((function(e){return e.endsWith(i)}))??-1;e>=0&&(window.renderWorker.activeNode=e)}n&&"file:"!=window.location.protocol&&window.history.pushState({path:i},"",i)}function p(e){const t=Array.from(e.querySelectorAll(".tree-container.file-tree .tree-item"));e.querySelectorAll(".tree-item-contents > .collapse-icon").forEach((function(e){e.addEventListener("click",(function(){var t;(t=e.parentElement.parentElement)&&o(t,!t.classList.contains("is-collapsed"))}))}));let i=e.querySelector(".tree-container.file-tree .collapse-tree-button");i&&i.addEventListener("click",(async function(){let e=i.classList.contains("is-collapsed");n(t,!e,t.length<100),i.classList.toggle("is-collapsed"),i.querySelector("iconify-icon").setAttribute("icon",e?"ph:arrows-out-line-horizontal-bold":"ph:arrows-in-line-horizontal-bold")}));let l=e.querySelector(".tree-container.outline-tree .collapse-tree-button");l&&l.addEventListener("click",(async function(){let e=l.classList.contains("is-collapsed"),t=Array.from(l.parentElement.parentElement.querySelectorAll(".tree-item"));n(t,!e,t.length<100),l.classList.toggle("is-collapsed"),l.querySelector("iconify-icon").setAttribute("icon",e?"ph:arrows-out-line-horizontal-bold":"ph:arrows-in-line-horizontal-bold")})),e.querySelectorAll(".tree-container .tree-item").forEach((function(e){e.classList.contains("is-collapsed")&&o(e,!0,!1)})),e.querySelectorAll(".tree-container > .tree-header > .collapse-tree-button").forEach((function(e){e.classList.contains("is-collapsed")?e.querySelector("iconify-icon").setAttribute("icon","ph:arrows-out-line-horizontal-bold"):e.querySelector("iconify-icon").setAttribute("icon","ph:arrows-in-line-horizontal-bold")}))}let h,g;function f(e){let t=e.querySelector("#root-path").getAttribute("root-path");document.querySelector("base").href=t,document.querySelector("#root-path").setAttribute("root-path",t),rootPath=t}let v=!1;function b(e){!function(e){function t(e,t=!1){let o=document.querySelector(".theme-toggle-input");if(o.checked=e,t){var n=document.body.style.transition;document.body.style.transition="none"}!o.classList.contains("is-checked")&&e?o.classList.add("is-checked"):o.classList.contains("is-checked")&&!e&&o.classList.remove("is-checked"),e?(document.body.classList.contains("theme-dark")&&document.body.classList.remove("theme-dark"),document.body.classList.contains("theme-light")||document.body.classList.add("theme-light")):(document.body.classList.contains("theme-light")&&document.body.classList.remove("theme-light"),document.body.classList.contains("theme-dark")||document.body.classList.add("theme-dark")),t&&setTimeout((function(){document.body.style.transition=n}),100),localStorage.setItem("theme_toggle",e?"true":"false")}null!=localStorage.getItem("theme_toggle")&&t("true"==localStorage.getItem("theme_toggle")),document.body.classList.contains("theme-light")?t(!0):t(!1),e.querySelector(".theme-toggle-input")?.addEventListener("change",(e=>{console.log("Theme toggle changed to: "+!("true"==localStorage.getItem("theme_toggle"))),t(!("true"==localStorage.getItem("theme_toggle")))}))}(e),function(e){e.querySelectorAll(".heading-collapse-indicator").forEach((function(e){e.addEventListener("click",(function(){var e=!this.parentElement.parentElement.classList.contains("is-collapsed");r(this.parentElement.parentElement,!e)}))})),e.querySelectorAll("a.internal-link, a.tree-item-link").forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=this.getAttribute("href");t.startsWith("#")&&(console.log("Uncollapsing header: "+t),r(document.getElementById(t.substring(1)).parentElement,!0))}))}))}(e),p(e),function(e){e.querySelectorAll(".callout.is-collapsible .callout-title").forEach((function(e){e.addEventListener("click",(function(){var t=this.parentElement;t.classList.contains("is-collapsed"),t.classList.toggle("is-collapsed"),e.querySelector(".callout-fold").classList.toggle("is-collapsed"),y(t.querySelector(".callout-content"),100)}))}))}(e),function(e){e.querySelectorAll(".task-list-item-checkbox").forEach((function(e){e.addEventListener("click",(function(){var e=this.parentElement;e.classList.toggle("is-checked"),e.setAttribute("data-task",e.classList.contains("is-checked")?"x":" ")}))})),e.querySelectorAll('.plugin-tasks-list-item input[type="checkbox"]').forEach((function(e){e.checked=e.parentElement.classList.contains("is-checked")})),e.querySelectorAll(".kanban-plugin__item.is-complete").forEach((function(e){e.querySelector('input[type="checkbox"]').checked=!0}))}(e),function(e){let t=null;e.querySelectorAll(".canvas-node-content-blocker").forEach((function(e){e.addEventListener("click",(function(){var e=this.parentElement.parentElement;e.classList.toggle("is-focused"),this.style.display="none",t&&(t.classList.remove("is-focused"),t.querySelector(".canvas-node-content-blocker").style.display=""),t=e}))}))}(e),function(e){e.querySelectorAll(".copy-code-button").forEach((function(t){t.addEventListener("click",(function(){var t=this.parentElement.querySelector("code").textContent;navigator.clipboard.writeText(t),this.textContent="Copied!",setTimeout((function(){e.querySelectorAll(".copy-code-button").forEach((function(e){e.textContent="Copy"}))}),2e3)}))}))}(e),function(e){e.querySelectorAll(".internal-link, .footnote-link, .tree-item-link").forEach((function(e){e.addEventListener("click",(function(t){let o=e.getAttribute("href");if(t.preventDefault(),o.startsWith("#")){let e=document.getElementById(o.substring(1));r(e.parentElement,!0),e.scrollIntoView()}else u(o,!0,!e.classList.contains("tree-item-link"))}))})),window.onpopstate=function(e){u(t(),!1)}}(e),function(e){function t(){let e=document.querySelector(".sidebar-right"),t=document.querySelector(".sidebar-left"),o=(e?1:0)+(t?1:0);if(0==o)return;if(h||(h=Math.max(e?.clientWidth,t?.clientWidth)),!g){let e=document.createElement("div");document.querySelector(".markdown-preview-view").appendChild(e),e.style.width="var(--line-width)",e.style.minWidth="var(--line-width)",e.style.maxWidth="var(--line-width)",g=e.clientWidth,e.remove()}let n=h*o+g/2;window.innerWidthint main() {
int x, y;
scanf("%d %d", &x, &y);
if(x < y){
printf("smaller: %d, larger:%d", x, y);
}
if(x >= y){
printf("smaller: %d, larger:%d", y, x);
}
return 0;
}
#include <stdio.h>
int main() {
int x, y, s, l;
scanf("%d %d", &x, &y);
if(x < y){
s = x;
l = y;
} else {
s = y;
l = x;
}
printf("smaller: %d, larger:%d\n", s, l);
return 0;
}
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if(n%2 == 0){
printf("even");
}else{
printf("odd");
}
return 0;
}
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a*a == b*b + c*c){
printf("yes");
}
if(b*b == a*a + c*c){
printf("yes");
}
if(c*c == a*a + b*b){
printf("yes");
}
return 0;
}
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a*a == b*b + c*c){
printf("yes");
} else {
if(b*b == a*a + c*c){
printf("yes");
} else {
if(c*c == a*a + b*b){
printf("yes");
} else {
printf("no");
}
}
}
return 0;
}
#include <stdio.h>
int main() {
int x;
scanf("%d", &x);
if(x>0)
{
printf("sign(x) = 1");
}
else if(x<0)
{
printf("sign(x) = -1");
}
else
{
printf("sign(x) = 0");
}
return 0;
}
#include <stdio.h>
int main()
{
float x, y, z;
scanf("%f %f %f", &x, &y, &z);
if (x > y)
{
if (x > z)
{
printf("%f", x);
}
else
{
printf("%f", z);
}
}
else
{
if (y > z)
{
printf("%f", y);
}
else
{
printf("%f", z);
}
}
return 0;
}
(is actually about loops)
#include <stdio.h>
int main() {
int n, i=1, p = 0;
while(i<=5){
scanf("%d", &n);
if(n>0) p++;
i++;
}
printf("positive: %d, negative: %d", p, 5-p);
return 0;
}
#include <stdio.h>
#include <math.h>
int main() {
float a, b, c, d, x1, x2;
scanf("%f %f %f", &a, &b, &c);
d = b*b - 4 * a * c;
printf("%f\n", d);
x1 = (-b + sqrt(d)) / (2*a);
x2 = (-b - sqrt(d)) / (2*a);
printf("%f, %f", x1, x2);
return 0;
}
#include <stdio.h>
int main()
{
int m,d;
scanf("%d %d", &m, &d);
if(m<7) printf("%d",(m-1)*31+d);
else printf("%d", (m-7)*30+6*31+d);
}
#include <stdio.h>
int main() {
float x,y,z, max, min;
scanf("%f %f %f", &x, &y, &z);
if(x>=y && y>=z){
max = x;
min = z;
}else if(x>=z && z >=y){
max = x;
min = y;
}else if(y>=x && x >= z){
max = y;
min = z;
}else if(y>= z && z >= x){
max = y;
min = x;
}else if(z>=x && x >= y){
max = z;
min = y;
}else{
max = z;
min = x;
}
printf("min=%f, max=%f", min, max);
return 0;
}
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a<b+c && b<a+c && c<a+b){
printf("triangle");
}
else{
printf("not triangle");
}
return 0;
}
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b){
printf("right triangle");
}else{
printf("not right triangle");
}
return 0;
}
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
switch(n) {
case 1:
printf("a");
break;
case 2:
printf("b");
break;
case 3:
printf("c");
break;
case 4:
printf("d");
break;
case 5:
printf("e");
break;
case 6:
printf("f");
break;
case 7:
printf("g");
break;
case 8:
printf("h");
break;
case 9:
printf("i");
break;
default:
printf("number isn't between 0 and 10.");
}
return 0;
}
for i in range(1,10):
print(f"\t\tcase {i}:\n\t\t\tprintf(\"{chr(i+96)}\");\n\t\t\tbreak;")
#include <stdio.h>
int main() {
int n = 4;
while(n<15) {
printf("%d\n",n);
n = n + 1;
}
return 0;
}
#include <stdio.h>
int main() {
int n = 28;
while(n<43) {
if(n%2==0) printf("%d\n",n);
n = n + 1;
}
return 0;
}
#include <stdio.h>
int main() {
int i = 4, n=0;
while(i<11) {
if(i%2==0) n++;
i = i + 1;
}
printf("%d", n);
return 0;
}
#include <stdio.h>
int main() {
int i=1, n=0;
while(i<11) {
n = n+i;
i = i+1;
}
printf("%d", n);
return 0;
}
#include <stdio.h>
int main() {
int i=1, n=1;
while(i<11) {
n = n*i;
i = i+1;
}
printf("%d", n);
return 0;
}
#include <stdio.h>
int main() {
float i=1, s=0, n;
while(i<=5) {
scanf("%f", &n);
s += n;
i += 1;
}
printf("%f", s/5);
return 0;
}
#include <stdio.h>
int main() {
float i=0, s=0, n=1;
while(n!=0) {
scanf("%f", &n);
s+=n;
i++;
}
printf("%f", s/(i-1));
return 0;
}
#include <stdio.h>
int main() {
float i=1, s=0;
while(i<=10) {
s+=1/i;
i++;
}
printf("%f", s);
return 0;
}
#include <stdio.h>
#include <math.h>
int main() {
int i = 1;
float s = 0;
while(i<10){
if(i%2==0) s-= 1.0/i;
else s += 1.0/i;
i++;
}
printf("%f", s);
return 0;
}
#include <stdio.h>
int main() {
int i=1;
float p=1, x, s = 0;
scanf("%f", &x);
while(i<=10){
if(i%2==0) s-= p/i;
else s += p/i;
i++;
p *= x;
}
printf("%f", s);
return 0;
}
#include <stdio.h>
int main() {
int i,n, max, min;
scanf("%d", &max);
min = max;
i=2;
while(i<=5){
scanf("%d", &n);
if(n > max) max = n;
else if (n < min) min = n;
i++;
}
printf("min =%d, max=%d", min, max);
return 0;
}
#include <stdio.h>
int main() {
int i,n, max1, max2;
scanf("%d", &max1, &max2);
i=2;
while(i<=10){
scanf("%d", &n);
if(n>max1){
max2 = max1;
max1 = n;
}else if(n>max2){
max2 = n;
}
i++;
}
printf("%d, %d", max1, max2);
return 0;
}
#include <stdio.h>
int main() {
int n, i = 2;
while(i<n){
if(i%n==0) break;
i++;
}
printf(n/i);
return 0;
}
#include <stdio.h>
int main() {
int x, y, res;
scanf("%d %d", &x, &y);
res = x<y ? x : y;
while (x%res != 0 || y%res != 0){
res -= 1;
}
printf("%d", res);
return 0;
}
#include <stdio.h>
int main() {
int n, i=1, f=1;
scanf("%d", &n);
while(i<=n){
f *= i;
i++;
}
printf("%d", f);
return 0;
}
#include <stdio.h>
int main() {
int n, count = 0;
scanf("%d", &n);
while(n>0){
if(n%10 == 2) count++;
n /= 10;
}
printf("%d", count);
return 0;
}
we can use below code to turn float to int
while(x-(int)x!=0) x *= 10;
#include <stdio.h>
int main() {
int base=1, bin, n=0;
scanf("%d", &bin);
while(bin>0){
n += base * (bin%10);
bin /= 10;
base *= 2;
}
printf("%d", n);
return 0;
}
#include <stdio.h>
int main() {
int i;
for(i=28; i<43; i+=2){
printf("%d\n", i);
}
return 0;
}
#include <stdio.h>
int main() {
float i, n, s=0;
for(i=0; i<10; i++){
scanf("%f", &n);
s += n;
}
printf("avg: %f", s/i);
return 0;
}
#include <stdio.h>
int main() {
float i, s=0, n=1;
for(i=0; n!=0; i++){
scanf("%f", &n);
s += n;
}
printf("%f", s/(i-1));
return 0;
}
#include <stdio.h>
int main() {
int i, n, f=1;
scanf("%d", &n);
for(i=1; i<=n; i++){
f *= i;
}
printf("%d", f);
return 0;
}
#include <stdio.h>
#include <math.h>
int main() {
int x, y, i, n=1;
scanf("%d %d", &x, &y);
if(y<1){
printf("exponent should be a positive number");
} else {
for(i=1; i<=y; i++){
n *= x;
}
printf("%d\n", n);
}
return 0;
}
#include <stdio.h>
int main(){
for(int i=1; i<=9; i++){
for(int j=1; j<=9; j++){
printf("%d\t", i*j);
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int x,y;
for(y=1; y<20; y++){
for(x=1; x<=y; x++){
printf("*");
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int n = 10;
int x, y;
for(y=0;y<n;y++){
for(x=0;x<n-y;x++) printf(" ");
for(x=0;x<2*y-1;x++) printf("*");
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
float i=0, s=0, n=1;
do {
scanf("%f", &n);
s+=n;
i++;
} while(n!=0);
printf("%f", s/(i-1));
return 0;
}
#include <stdio.h>
int main() {
int a[10], s=0;
for(int i=0; i<10; i++) scanf("%d", &a[i]);
for(int i=0; i<10; i++) s+= a[i];
printf("sum: %d\n", s);
for(int i=0; i<10; i++) printf("%d\n", a[i]);
return 0;
}
#include <stdio.h>
int main() {
int a[10];
for(int i=0; i<10; i++) scanf("%d", &a[i]);
for(int i=9; i>=0; i--) printf("%d\n", a[i]);
return 0;
}
#include <stdio.h>
int main() {
int n;
scand("%d", &n);
while(n>0){
printf("%d", n%10);
n /= 10;
}
return 0;
}
#include <stdio.h>
int main() {
int a[20];
for(int i=0; i<20; i++) a[i] = 10 + i*2;
for(int i=0; i<20; i++) printf("%d\n", a[i]);
return 0;
}
#include <stdio.h>
int main() {
int bin[10], n, i = 0;
scanf("%d", &n);
while (n > 0) {
bin[i] = n % 2;
n /= 2;
i++;
}
for (int j = i-1; j>=0; j--) printf("%d", bin[j]);
return 0;
}
#include <stdio.h>
int main() {
char c;
float a[10], res;
for(int i=0; i<10; i++) scanf("%f\n", &a[i]);
printf("charachter: ");
scanf("%c", &c);
if (c=='m'){
res = 1;
for(int i=0; i<10; i++) res*=a[i];
}else{
res = 0;
for(int i=0; i<10; i++) res+=a[i];
if(c=='a') res /= 10;
}
printf("result: %f", res);
return 0;
}
#include <stdio.h>
int main(){
int a[5], b[5], c[5], n=0;
for(int i=0; i<5; i++)
scanf("%d", &a[i]);
for(int i=0; i<5; i++)
scanf("%d", &b[i]);
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
if (a[i] == b[j]){
c[n] = a[i];
n++;
}
}
}
for(int i=0; i<n; i++){
printf("%d\n", c[i]);
}
}
#include <stdio.h>
int main() {
int a[10], n, freq=0;
for(int i=0; i<10; i++) scanf("%d", &a[i]);
printf("number: ");
scanf("%d", &n);
for(int i=0; i<10; i++){
if (a[i]==n) freq++;
}
printf("frequency: %d", freq);
return 0;
}
#include <stdio.h>
int main(){
int a[10], c;
for(int i=0; i<10; i++){
scanf("%d", &a[i]);
}
for(int i=0; i<10; i++){
c = 0;
for(int j=0; j<i; j++){
if (a[i] == a[j]) c++;
}
if (c!=0) continue;
for(int j=i; j<10; j++){
if (a[i] == a[j]) c++;
}
printf("%d: %d\n", a[i], c);
}
}
#9432;From now on I tried to follow problem numbers solved in the class are an 's' to distinguish them.
#include <stdio.h>
int main(){
int a[10];
for(int i=0; i<10; i++){
scanf("%d", &a[i]);
}
for(int i=0; i<10; i++){
printf("%d:\t", a[i]);
for(int j=0; j<a[i]; j++) printf("#");
printf("\n");
}
}
#include <stdio.h>
int main(){
int a[10], n, index = -1, len=10;
for(int i=0; i<len; i++){
scanf("%d", &a[i]);
}
scanf("%d", &n);
for(int i=0; i<len; i++){
if(a[i] == n) {
index = i;
break;
}
}
if (index>=0){
len--;
for(;index<len;index++){
a[index] = a[index+1];
}
}
for(int i=0;i<len;i++) printf("%d\n",a[i]);
}
#include <stdio.h>
int main(){
int a[6], n;
for(int i=1; 6; i++){
scanf("%d\n", &a[i]);
}
printf("number: ");
scanf("%d", &a[0]);
for(int i=0;i<6;i++) printf("%d\n",a[i]);
}
#include <stdio.h>
int main(){
int a[10], n, len=5;
for(int i=0; i<len; i++){
scanf("%d", &a[i]);
}
printf("number: ");
scanf("%d", &n);
len++;
for(int i=len; i>0; i--){
a[i] = a[i-1];
}
a[0] = n;
for(int i=0;i<len;i++) printf("%d\n", a[i]);
}
#include <stdio.h>
int main(){
int a[10], i,j, temp;
for(int i=0; i<5; i++){
scanf("%d", &a[i]);
}
printf("indices:\n");
scanf("%d %d", &i, &j);
temp = a[i];
a[i] = a[j];
a[j] = temp;
printf("new list:\n");
for(int i=0;i<5;i++) printf("%d\n", a[i]);
}
#include <stdio.h>
int main(){
int a[100][100] = {0}, h,w,k,r,c,v;
//h:rows(height), w:columns(width), k: number of non-zero items
scanf("%d %d %d", &h, &w, &k);
for(int i=0; i<k; i++){
printf("enter matrix element row, column and value(element %d/%d):\n", i+1, k);
scanf("%d %d %d", &r, &c, &v);
a[r-1][c-1] = v;
}
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
printf("%d\t", a[i][j]);
}
printf("\n");
}
}
#include <stdio.h>
int main() {
int a[5], i, j, temp;
for (i = 0; i < 5; i++) scanf("%d", &a[i]);
for(i=0;i<5-1;i++){
for(j=0;j<5-i-1;j++){
if(a[j]>a[j+1]){
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
printf("sorted array:\n");
for(i = 0;i<5;i++) printf("%d\n",a[i]);
return 0;
}
#include <stdio.h>
int main() {
int a[5], i, j, max_index, temp;
for (i=0; i<5; i++) scanf("%d", &a[i]);
for (i=0; i<5-1; i++) {
max_index = i;
for (j=i+1; j<5; j++) {
if (a[j] > a[max_index]) max_index = j;
}
temp = a[i];
a[i] = a[max_index];
a[max_index] = temp;
}
printf("sorted array:\n");
for (i=0; i<5; i++) printf("%d\n", a[i]);
return 0;
}
#include <stdio.h>
int main() {
int a[5], i, j, min_index, temp;
for (i=0; i<5; i++) scanf("%d", &a[i]);
for (i=0; i<5-1; i++) {
min_index = i;
for (j=i+1; j<5; j++) {
if (a[j] < a[min_index]) min_index = j;
}
temp = a[i];
a[i] = a[min_index];
a[min_index] = temp;
}
printf("sorted array:\n");
for (i=0; i<5; i++) printf("%d\n", a[i]);
return 0;
}
#include <stdio.h>
int main() {
int a[5], b[5], i, j,k;
for (i=0; i<5; i++) scanf("%d", &a[i]);
for (i=0; i<5; i++) {
j = 0;
while(j<i && a[i]>b[j]) j++;
for(k=i;k>=j;k--){
b[k] = b[k-1];
}
b[j] = a[i];
}
printf("sorted array:\n");
for (i=0; i<5; i++) printf("%d\n", b[i]);
return 0;
}
#include <stdio.h>
int main() {
int a[5], b[5], i, j;
for (i=0; i<5; i++) scanf("%d", &a[i]);
for (i=0; i<5; i++) {
j = i-1;
while(j>=0 && b[j]>a[i]){
b[j+1] = b[j];
j--;
}
b[j+1] = a[i];
}
printf("sorted array:\n");
for (i=0; i<5; i++) printf("%d\n", b[i]);
return 0;
}
#include <stdio.h>
int main() {
int a[11] = {1,3,4,6,8,9,10,15,18,18,21},l=0,r=10, m ,n;
scanf("%d", &n);
while(l<=r){
m = (l+r)/2;
if(a[m]<n) l = m+1;
else if(a[m]>n) r = m-1;
else break;
}
if(a[m] == n) printf("%d", m);
else{
printf("number doesn't exist in array");
}
return 0;
}
#include <stdio.h>
int main() {
int i, j, max, r=0, c=0;
/* value of a is just an example */
int a[3][3] = {{3,7,9},{23,4,6},{5,14,6}};
max = a[0][0];
for (i = 0; i < 3; i++)
{
for(j=0; j<3; j++){
if(max<a[i][j]) {
r = i;
c = j;
max = a[i][j];
}
}
}
printf("max: a[%d][%d] = %d", r, c, max);
return 0;
}
#include <stdio.h>
int main() {
int i, j, k;
/* a here is just an example */
int a[3][3] = {{3,7,9},{23,4,6},{5,14,6}};
scanf("%d", &k);
for (i = 0; i < 3; i++)
{
a[2][i] = a[2][i] - k*a[1][i];
}
for (i = 0; i < 3; i++)
{
for(j=0; j<3; j++){
printf("%d\t", a[i][j]);
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int i, j, a[20], m[4][5];
/* I'm just gonna assume array is list has
numbers from 1 to 20 in it for convenience */
for(i=1;i<=20;i++){
a[i-1] = i;
}
/* solution begins: */
for(i=0; i<20; i++){
m[i/5][i%5] = a[i];
}
for (i = 0; i < 4; i++)
{
for(j=0; j<5; j++){
printf("%d\t", m[i][j]);
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int i, j, a[20];
/* a here is just an example */
int m[4][5] = {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20}};
for (i = 0; i < 4; i++)
{
for(j=0; j<5; j++){
a[i*5+j] = m[i][j];
}
}
for(i=0; i<20; i++){
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
#include <stdio.h>
int main() {
int i, j, c;
/* a here is just an example */
int m[4][5] = {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20}};
scanf("%d", &c);
for (i = 0; i < 4; i++)
{
for(j=c; j<4; j++){
m[i][j] = m[i][j+1];
}
}
printf("new matrix:\n");
for (i = 0; i < 4; i++)
{
for(j=0; j<4; j++){
printf("%d\t", m[i][j]);
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int i, j, m2[5][4];
/* a here is just an example */
int m1[4][5] = {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20}};
for (i = 0; i < 4; i++)
{
for(j=0; j<5; j++){
m2[j][i] = m1[i][j];
}
}
printf("new matrix:\n");
for (i = 0; i < 5; i++)
{
for(j=0; j<4; j++){
printf("%d\t", m2[i][j]);
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int i, j, m[2][2];
/* values of m1 and m2 are just for testing */
int m1[2][2] = {{4,2},{6,7}}, m2[2][2] = {{1,3},{5,8}};
for (i = 0; i < 2; i++)
{
for(j=0; j<2; j++){
m[i][j] = m1[i][j] + m2[i][j];
}
}
printf("new matrix:\n");
for (i = 0; i < 2; i++)
{
for(j=0; j<2; j++){
printf("%d\t", m[i][j]);
}
printf("\n");
}
return 0;
}
#include <stdio.h>
int main() {
int i, j, k, m[3][3] = {0};
/* values of m1 and m2 are just for testing */
int m1[3][2] = {{4,2},{6,7},{3,1}}, m2[2][3] = {{1,3,5},{8,7,9}};
/* [0,m1 rows]*/
for (i=0; i<3; i++)
{
/* [0,m2 columns]*/
for(j=0; j<3; j++){
/* [0,m1 columns]*/predictable
for(k=0; k<2; k++)
{
m[i][j] += m1[i][k] * m2[k][j];
}
}
}
printf("m1 × m2 :\n");
for (i = 0; i < 3; i++)
{
for(j=0; j<3; j++){
printf("%d\t", m[i][j]);
}
printf("\n");
}
return 0;
}
int max(int a, int b){
if (a>b) return a;
else return b;
}
#include <stdio.h>
float avg(float a, float b){
return (a+b)/2;
}
int main() {
printf("%f\n", avg(5,4));
printf("%f\n", avg(1000,0));
printf("%f\n", avg(1,10));
printf("%f\n", avg(-10,342));
/* many timesss!! */
return 0;
}
#include <stdio.h>
float d2r(float d){
return d / 180 * 3.14159;
}
int main() {
float i;
for(i=0; i<=10; i++){
// at small angles, sin(x) ≈ x
printf("sin(%f) = %f\n", i, d2r(i));
}
return 0;
}
#include <stdio.h>
int pow5(int n) {
int i, p=1;
for (i = 0; i < 5; i++) {
p *= n;
}
return p;
}
int main() {
int i;
for (i = 0; i <= 10; i++) {
printf("%d\n", pow5(i));
}
return 0;
}
#include <stdio.h>
int factorial(int n){
int res = 1;
for(int i=1; i<=n; i++) res*=i;
return res;
}
int main(){
int sum = 0, x;
float soorat;
scanf("%d", &x);
for(int i=1; i<=10; i++){
sum += soorat/factorial(i);
soorat*=-x;
}
}
int max(int a[], int len){
int res;
res = a[0];
for(int i=1; i<len; i++){
if(a[i]>res) res = a[i];
}
return res;
}
#include <stdio.h>
#include <math.h>
float dumb_variable;
void distance(float x, float y, float z){
dumb_variable = sqrt(x*x + y*y + z*z);
}
int main() {
float x,y,z;
scanf("%f %f %f", &x, &y, &z);
distance(x, y, z);
printf("distance: %f", dumb_variable);
return 0;
}
#include <stdio.h>
void cross_product(float a[], float b[], float c[]){
c[0] = a[1]*b[2] - a[2]*b[1];
c[1] = a[2]*b[0] - a[0]*b[2];
c[2] = a[0]*b[1] - a[1]*b[0];
}
int main() {
float a[3] = {2,6,34}, b[3]={5,8.2,1}, c[3];
cross_product(a, b, c);
// should be -272.8, 168, -13.8
printf("%f, %f, %f", c[0], c[1], c[2]);
}
#include <stdio.h>
/* runs a binary search on array 'a' with last index
'r' and returns first index containing value */
int binary_search(int a[], int r, int value){
int l=0, m;
while(l<=r){
m = (l+r)/2;
if(a[m]>value) r = m-1;
else if(a[m]<value) l = m+1;
else return m;
}
return l;
}
/* sort array 'a' with length 'len' into
array 'b' using binary insertion sort */
void sort(int a[], int b[], int len) {
int i, j, pos;
for (i=0; i<len; i++) {
/* j is last index available in the array */
j = i-1;
pos = binary_search(b, j, a[i]);
while(j>=pos){
b[j+1] = b[j];
j--;
}
b[j+1] = a[i];
}
}
int main() {
int a[5] = {1,5,52,3,15}, b[5], i;
sort(a,b,5);
for(i=0; i<5; i++) printf("%d ", b[i]);
return 0;
}
#include <stdio.h>
/* eliminates element at index 'n'
in array 'a' wieh length 'l' */
void eliminate(int a[], int l, int n){
int i;
for(i=n; i<l-1; i++){
a[i] = a[i+1];
}
}
int main() {
int a[7] = {2,6,3,5,3,3,6}, i ,j, len=7;
for(i=0; i<len; i++){
for(j=i+1; j<len; j++){
if (a[i]==a[j]){
eliminate(a, len, j);
len--;
j--;
continue;
}
}
}
printf("array without duplicates: ");
for(i=0; i<len; i++) printf("%d ", a[i]);
return 0;
}
written by ΛM!N