Created
October 24, 2013 03:42
-
-
Save arumaru/7130963 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fyrst er að fá inntak. Í sömu línu er hver stafur gerður lágstafur. | |
# Þetta er gert til að auðvelda talninguna. | |
strengur = gets.chomp.downcase! | |
stafrof = ('a'..'z').to_a | |
# Núna búum við til for-lykkju sem fer í gegnum öll 26 gildi enska stafrófsins. | |
for i in 0..25 | |
# Innihaldi strengurinn þann staf sem lykkjan skoðar því sinni, | |
# þá prentar forritið fjöldann*stafinn skv. tilmælum. | |
if strengur.include? stafrof[i] | |
print strengur.count(stafrof[i]) | |
print "*#{stafrof[i]}, " | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment