Compare commits

...

6 Commits

Author SHA1 Message Date
8bf03aa5b8 Edit readme again 2022-03-26 15:15:55 +01:00
dd2a0a1f5d Edit readme 2022-03-26 15:15:26 +01:00
d408dc4da2 Removed redundant if condition 2022-03-26 15:13:26 +01:00
6fff53bc0c Beautiful bash code :) 2022-03-26 15:11:48 +01:00
841be2bee6 Readme 2022-03-26 15:11:28 +01:00
2eb903e6bc Add gitignore 2022-03-26 14:55:22 +01:00
3 changed files with 118 additions and 0 deletions

75
.gitignore vendored Normal file
View File

@@ -0,0 +1,75 @@
# Created by https://www.toptal.com/developers/gitignore/api/linux,windows,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,windows,macos
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.toptal.com/developers/gitignore/api/linux,windows,macos

View File

@@ -1,2 +1,10 @@
# Triangles
## Descrizione esercizio
Dato un numero intero n, produrre in output un triangolo rettangolo in cui i cateti sono lunghi n e il perimetro sia delineato con il carattere * in ogni punto.
I cateti devono essere in alto e a sinistra. Esempio, dato n=5:
## Come eseguire
Lanciare ```./Triangles.sh``` oppure ```bash Triangles.sh```

35
Triangles.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
# Dato un numero intero n, produrre in output un triangolo rettangolo in cui i
# cateti sono lunghi n e il perimetro sia delineato con il carattere * in ogni punto.
# I cateti devono essere in alto e a sinistra. Esempio, dato n=5:
echo -n "Lato triangolo: "
read lato
printf "\n"
if [ $lato == 1 ]
then
echo "*"
elif [ $lato -lt 1 ]
then
echo "Lato non valido"
else
printf "%0.s*" $(seq 1 $lato)
printf "\n"
for i in $(seq 1 $(( $lato - 1 )))
do
printf "*"
spazi=$(( $lato - $i - 2 ))
if [ $spazi -gt 0 ]
then
printf "%0.s " $(seq 1 $spazi)
fi
if [ $spazi -gt -1 ]
then
printf "*\n"
fi
done
printf "\n"
fi