text = 'The rain in Spain falls mainly in the plain.'first = Hash.new []second = Hash.new {|hash,key| hash[key] = []} text.split(/\W+/).each do |word| p "word: #{word}" p first[word[0, 1].downcase].object_id first[word[0, 1].downcase] << w
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); String s = in.nextLine(); CodeLength(s); } public static void CodeLength(String s){ String [] str = s.split(" "); int lengt
1.题目: Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". 运用到了栈的思想.先进后出,这样就逆序了. 时间复杂度,就是整个程序在运行过程中,每个小模块运行的次数之和. 时间复杂度指运行时间需求,空间复杂度是指运行空间需求. public class toChar1{ pu
1. 要求: 给定一篇纯英文的文本,统计其中回文单词的比列,并输出其中的回文单词,文本数据如下: This is Everyday Grammar. I am Madam Lucija And I am Kaveh. Why the title, Lucija? Well, it is a special word. Madam? Yeah, maybe I should spell it for you forward or backward? I am lost. The word Mada
Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging. 统计输入中单词的长度,并且绘制相应的直方图.水平的直方图比较容易绘制,垂直的直方图较困难一些. /* This program was the