Compare commits
6 Commits
12dd97e614
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8bf03aa5b8 | |||
| dd2a0a1f5d | |||
| d408dc4da2 | |||
| 6fff53bc0c | |||
| 841be2bee6 | |||
| 2eb903e6bc |
75
.gitignore
vendored
Normal file
75
.gitignore
vendored
Normal 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
|
||||
@@ -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
35
Triangles.sh
Executable 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
|
||||
Reference in New Issue
Block a user