Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Nth/UNIX-Shell/nth.sh
Normal file
16
Task/Nth/UNIX-Shell/nth.sh
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
nth() {
|
||||
local ordinals=(th st nd rd)
|
||||
local -i n=$1 i
|
||||
if (( n < 0 )); then
|
||||
printf '%s%s\n' - "$(nth $(( -n )) )"
|
||||
return 0
|
||||
fi
|
||||
case $(( n % 100 )) in
|
||||
11|12|13) i=0;;
|
||||
*) (( i= n%10 < 4 ? n%10 : 0 ));;
|
||||
esac
|
||||
printf '%d%s\n' "$n" "${ordinals[i]}"
|
||||
}
|
||||
for n in {0..25} {250..265} {1000..1025}; do
|
||||
nth $n
|
||||
done | column
|
||||
Loading…
Add table
Add a link
Reference in a new issue