diff options
| author | Jacob McDonnell <jacob@simplelittledream.com> | 2021-11-01 11:10:32 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@simplelittledream.com> | 2021-11-01 11:10:32 -0400 |
| commit | cb7e1688c61dc6861d06b56475f46d5c7ac75f91 (patch) | |
| tree | 012dedf66466fd30a927f740169bc852617010d4 | |
| parent | fe5e287e5d517bb301ab403bcc0b92ff89dbdc3e (diff) | |
Updated coin to allow for multiple flips
| -rw-r--r-- | .DS_Store | bin | 6148 -> 6148 bytes | |||
| -rw-r--r-- | .vscode/configurationCache.log | 2 | ||||
| -rw-r--r-- | .vscode/dryrun.log | 2 | ||||
| -rw-r--r-- | .vscode/targets.log | 22 | ||||
| -rw-r--r-- | README.txt (renamed from ProjectMustang.txt) | 2 | ||||
| -rw-r--r-- | src/cmd/coin/coin.c | 49 | ||||
| -rw-r--r-- | src/cmd/dice/dice.c | 2 | ||||
| -rw-r--r-- | src/cmd/echo/echo.c | 2 |
8 files changed, 58 insertions, 23 deletions
| Binary files differ diff --git a/.vscode/configurationCache.log b/.vscode/configurationCache.log index c60bec6..3fb4b13 100644 --- a/.vscode/configurationCache.log +++ b/.vscode/configurationCache.log @@ -1 +1 @@ -{"buildTargets":["all","clean","cmd/.","coin/.","dice/.","echo/.","install","src"],"launchTargets":["/Users/jmm/Documents/git/ProjectMustang/src/cmd/coin>coin()","/Users/jmm/Documents/git/ProjectMustang/src/cmd/dice>dice()","/Users/jmm/Documents/git/ProjectMustang/src/cmd/echo>echo()"],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":["/Users/jmm/Documents/git/ProjectMustang/src/cmd/coin","/Users/jmm/Documents/git/ProjectMustang/src/cmd/dice","/Users/jmm/Documents/git/ProjectMustang/src/cmd/echo"],"compilerArgs":["-o","echo","echo.c"]},"fileIndex":[["/Users/jmm/Documents/git/ProjectMustang/src/cmd/coin/coin.c",{"uri":{"$mid":1,"fsPath":"/Users/jmm/Documents/git/ProjectMustang/src/cmd/coin/coin.c","path":"/Users/jmm/Documents/git/ProjectMustang/src/cmd/coin/coin.c","scheme":"file"},"configuration":{"defines":[],"standard":"c11","includePath":[],"forcedInclude":[],"intelliSenseMode":"clang-x64","compilerPath":"/usr/bin/cc","compilerArgs":["-o","coin","coin.c"],"windowsSdkVersion":""}}],["/Users/jmm/Documents/git/ProjectMustang/src/cmd/dice/dice.c",{"uri":{"$mid":1,"fsPath":"/Users/jmm/Documents/git/ProjectMustang/src/cmd/dice/dice.c","path":"/Users/jmm/Documents/git/ProjectMustang/src/cmd/dice/dice.c","scheme":"file"},"configuration":{"defines":[],"standard":"c11","includePath":[],"forcedInclude":[],"intelliSenseMode":"clang-x64","compilerPath":"/usr/bin/cc","compilerArgs":["-o","dice","dice.c"],"windowsSdkVersion":""}}],["/Users/jmm/Documents/git/ProjectMustang/src/cmd/echo/echo.c",{"uri":{"$mid":1,"fsPath":"/Users/jmm/Documents/git/ProjectMustang/src/cmd/echo/echo.c","path":"/Users/jmm/Documents/git/ProjectMustang/src/cmd/echo/echo.c","scheme":"file"},"configuration":{"defines":[],"standard":"c11","includePath":[],"forcedInclude":[],"intelliSenseMode":"clang-x64","compilerPath":"/usr/bin/cc","compilerArgs":["-o","echo","echo.c"],"windowsSdkVersion":""}}]]}}
\ No newline at end of file +{"buildTargets":["all","clean","install","src"],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}}
\ No newline at end of file diff --git a/.vscode/dryrun.log b/.vscode/dryrun.log index 4edcbd5..51f061e 100644 --- a/.vscode/dryrun.log +++ b/.vscode/dryrun.log @@ -1,4 +1,4 @@ -make all -f "/Users/jmm/Documents/git/ProjectMustang/makefile" --dry-run --keep-going --print-directory
+make all -f "/Users/jmm/Documents/git/ProjectMustang/makefile" --dry-run --always-make --keep-going --print-directory
make: Entering directory `/Users/jmm/Documents/git/ProjectMustang' make: Nothing to be done for `all'. make: Leaving directory `/Users/jmm/Documents/git/ProjectMustang' diff --git a/.vscode/targets.log b/.vscode/targets.log index 1ccc479..0d9e783 100644 --- a/.vscode/targets.log +++ b/.vscode/targets.log @@ -6,13 +6,11 @@ make all -f "/Users/jmm/Documents/git/ProjectMustang/makefile" --print-data-base # PARTICULAR PURPOSE. # This program built for i386-apple-darwin11.3.0 -
-# Make data base, printed on Sun Oct 10 19:18:58 2021 +# Make data base, printed on Mon Nov 1 10:33:21 2021 # Variables -
# automatic <D = $(patsubst %/,%,$(dir $<)) # automatic @@ -44,7 +42,7 @@ INFOPATH = /opt/homebrew/share/info: # environment PLAN9 = /opt/plan9port # environment -VSCODE_IPC_HOOK_EXTHOST = /var/folders/qq/frtrjqf10vlcgdw8_fwlhm_c0000gn/T/vscode-ipc-02e54fef-6923-4e13-a59c-f729dc06389a.sock +VSCODE_IPC_HOOK_EXTHOST = /var/folders/qq/frtrjqf10vlcgdw8_fwlhm_c0000gn/T/vscode-ipc-6442ebc7-8e85-4d28-b0e2-f9a0fc3ed687.sock # environment VSCODE_CWD = / # environment @@ -58,13 +56,13 @@ ELECTRON_RUN_AS_NODE = 1 # default .FEATURES := target-specific order-only second-expansion else-if archives jobserver check-symlink # environment -SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.C9Ivjs9yNA/Listeners +SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.rBEHA7GWj3/Listeners # automatic %F = $(notdir $%) # makefile (from `/Users/jmm/Documents/git/ProjectMustang/makefile', line 1) (CC) = clang # environment -DISPLAY = /private/tmp/com.apple.launchd.peroWlR96r/org.xquartz:0 +DISPLAY = /private/tmp/com.apple.launchd.gZJXoHdnVC/org.xquartz:0 # automatic *F = $(notdir $*) # environment @@ -86,7 +84,7 @@ XDG_CACHE_HOME = /Users/jmm/.cache # default MAKEFILEPATH := /Applications/Xcode.app/Contents/Developer/Makefiles # environment -VSCODE_CODE_CACHE_PATH = /Users/jmm/Library/Application Support/VSCodium/CachedData/ee8c7def80afc00dd6e593ef12f37756d8f504ea +VSCODE_CODE_CACHE_PATH = /Users/jmm/Library/Application Support/VSCodium/CachedData/6cba118ac49a1b88332f312a8f67186f7f3c1643 # environment LOGNAME = jmm # environment @@ -126,7 +124,7 @@ TMPDIR = /var/folders/qq/frtrjqf10vlcgdw8_fwlhm_c0000gn/T/ # environment CEDEV = /opt/CEdev # environment -VSCODE_IPC_HOOK = /Users/jmm/Library/Application Support/VSCodium/1.61.0-main.sock +VSCODE_IPC_HOOK = /Users/jmm/Library/Application Support/VSCodium/1.61.2-main.sock # makefile MAKEFLAGS = Rrqp # environment @@ -136,7 +134,7 @@ MFLAGS = -Rrqp # environment HOMEBREW_SHELLENV_PREFIX = /opt/homebrew # environment -XPC_SERVICE_NAME = application.com.visualstudio.code.oss.19706844.19706849 +XPC_SERVICE_NAME = application.com.visualstudio.code.oss.20131101.20131106 # environment HOMEBREW_PREFIX = /opt/homebrew # automatic @@ -178,9 +176,8 @@ SUBDIRS := src # environment LANG = C # environment -VSCODE_PID = 70512 +VSCODE_PID = 28450 # variable set hash-table stats: -
# Load=83/1024=8%, Rehash=0, Collisions=3/113=3% # Pattern-specific Variable Values @@ -201,7 +198,6 @@ VSCODE_PID = 70512 all: # Phony target (prerequisite of .PHONY). # Command-line target. -
# Implicit rule search has not been done. # File does not exist. # File has been updated. @@ -274,6 +270,6 @@ install: # strcache size: total = 4096 / max = 4096 / min = 4096 / avg = 4096 # strcache free: total = 4047 / max = 4047 / min = 4047 / avg = 4047 -# Finished Make data base on Sun Oct 10 19:18:58 2021 +# Finished Make data base on Mon Nov 1 10:33:21 2021 diff --git a/ProjectMustang.txt b/README.txt index 0ba4eac..f242343 100644 --- a/ProjectMustang.txt +++ b/README.txt @@ -5,7 +5,7 @@ Overview: A UNIX-like operating system with the graphical environment of a 90s o Features: - Full desktop environment similar to windows 9x - - Programmer based environment with tools to make programming, and gui programming easier, like NeXTSTEP + - Programmer based environment with tools to make programming, and gui programming, easier; like NeXTSTEP - UNIX-like userland tools - Networking - Support for multiple programming languages like C, C++, GOLANG, and mabye Java diff --git a/src/cmd/coin/coin.c b/src/cmd/coin/coin.c index 09ca479..5c58b3c 100644 --- a/src/cmd/coin/coin.c +++ b/src/cmd/coin/coin.c @@ -1,15 +1,54 @@ #include <stdio.h> #include <stdlib.h> #include <time.h> +#include <string.h> + +int coinFlip (int times); int -main (void) +main (int argc, char *argv[]) { - int c; - time_t t; - srand((unsigned) time(&t)); + int nflag = 0, i, times = 1, tails, heads; + argc--; - printf("%s\n", (rand() % 2) ? "Heads" : "Tails"); + for (i = 1; i <= argc; i++) { + if (strcmp(argv[i], "-n") == 0) + nflag++; + else if (nflag == 1) + times = atoi(argv[i]); + if (times == 0) { + printf("Non Integer Value Inputted\n"); + return -1; + } + } + if (times == 1) + printf("%s\n", coinFlip(times) ? "Heads" : "Tails"); + else { + tails = coinFlip(times); + heads = times - tails; + float ph = (float)heads/times, pt = (float)tails/times; + + printf("Heads: %d\nTails: %d\nProb Heads: %f\nProb Tails: %f\n", heads, tails, ph, pt); + } return 0; } + +/* coinFlip: Flips a coin n numbers of times and returns the number of tails */ +int +coinFlip (int times) +{ + int tails, i, c; + time_t t; + srand((unsigned) time(&t)); + + tails = 0; + + for (i = 0; i < times; i++) { + c = rand() % 2; + if (c == 1) + tails++; + } + + return tails; +}
\ No newline at end of file diff --git a/src/cmd/dice/dice.c b/src/cmd/dice/dice.c index b31670f..f211d67 100644 --- a/src/cmd/dice/dice.c +++ b/src/cmd/dice/dice.c @@ -12,4 +12,4 @@ main (void) printf("%d\n", (rand() % sides) + 1); return 0; -} +}
\ No newline at end of file diff --git a/src/cmd/echo/echo.c b/src/cmd/echo/echo.c index 4733830..3dc8334 100644 --- a/src/cmd/echo/echo.c +++ b/src/cmd/echo/echo.c @@ -14,4 +14,4 @@ main (int argc, char *argv[]) printf("%s%c", argv[i], (i == argc) ? ((nflag == 1) ? '\0' : '\n') : ' '); } return 0; -} +}
\ No newline at end of file |
