From 8fa79ad566b01ccf88e1839ee7bafe483c54c45e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 17 May 2026 21:25:27 +0200 Subject: [PATCH] hw --- .gitignore | 206 +++++++++++++++++- .../5-2-4_number_comparison.c | 18 ++ .../numberreversal.c | 24 ++ .../timeconverter.c | 30 +++ 4 files changed, 269 insertions(+), 9 deletions(-) create mode 100644 med/C-programming-a-modern-standard/5-2-4_number_comparison.c create mode 100644 med/C-programming-a-modern-standard/numberreversal.c create mode 100644 med/C-programming-a-modern-standard/timeconverter.c diff --git a/.gitignore b/.gitignore index 55c2c13..1524431 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,7 @@ -.DS_Store -.idea -*.log -tmp/ - -*.class -build +# Created by https://www.toptal.com/developers/gitignore/api/node,vscode,emacs,c +# Edit at https://www.toptal.com/developers/gitignore?templates=node,vscode,emacs,c +### C ### # Prerequisites *.d @@ -59,5 +55,197 @@ Module.symvers Mkfile.old dkms.conf -# debug information files -*.dwo +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +#!! ERROR: vscode is undefined. Use list command to see defined gitignore types !!# + +# End of https://www.toptal.com/developers/gitignore/api/node,vscode,emacs,c diff --git a/med/C-programming-a-modern-standard/5-2-4_number_comparison.c b/med/C-programming-a-modern-standard/5-2-4_number_comparison.c new file mode 100644 index 0000000..2861f52 --- /dev/null +++ b/med/C-programming-a-modern-standard/5-2-4_number_comparison.c @@ -0,0 +1,18 @@ +#include "stdio.h" + +int main() +{ + int i = 5; + int j = 7; + int x; + + x = (i>j)-(j>i); + /* + * -1 if i less than j + * 0 if i equal to j + * +1 if i more than j + * */ + + printf("%d: ", x); + return 0; +} diff --git a/med/C-programming-a-modern-standard/numberreversal.c b/med/C-programming-a-modern-standard/numberreversal.c new file mode 100644 index 0000000..b451b22 --- /dev/null +++ b/med/C-programming-a-modern-standard/numberreversal.c @@ -0,0 +1,24 @@ +#include "stdio.h" +#include "stdlib.h" + +int main(){ + + int input; + printf("input:"); + scanf("%d", &input); + + // assume 3 digits, + + int d1, d2, d3; + d1 = input / 100; //uitgaande van flooring + d2 = input % 100 / 10; + d3 = input % 10; + + printf("%d%d%d",d3, d2,d1); + + printf("next: "); + scanf("%1d%1d%1d", &d1,&d2,&d3); + printf("%d%d%d",d3,d2,d1); + + return 0; +} diff --git a/med/C-programming-a-modern-standard/timeconverter.c b/med/C-programming-a-modern-standard/timeconverter.c new file mode 100644 index 0000000..e4549b5 --- /dev/null +++ b/med/C-programming-a-modern-standard/timeconverter.c @@ -0,0 +1,30 @@ +#include "stdio.h" + +int main() +{ + + /* + * modify 24 hour time to 12 hour + * take first 2 numbers, + * if numbers <=12, AM + * else PM + * */ + + int i ; int j; char c; + printf("input time: "); + scanf("%2d%1c%2d", &i,&c, &j); + printf("int i: %d int j: %d\n", i, j); + + if(i!=12&&j==00){ + i%=12; + } + + + if(i <=12){ + printf("%d:%.2d AM",i,j); + } else { + printf("%d:%.2d PM",i,j); + } + + return 0; +}