From 9521e2aa55486842d4467cfdcca8b2446ec033b1 Mon Sep 17 00:00:00 2001 From: RealAnalysis Date: Sat, 18 Apr 2020 23:12:10 +0800 Subject: [PATCH 1/3] 01 --- 01-hello.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/01-hello.rb b/01-hello.rb index e0e7bbf..f0e0216 100644 --- a/01-hello.rb +++ b/01-hello.rb @@ -1,8 +1,7 @@ # 题目: 输入名字,输出 "Hello, 名字" print "请输入你的名字,然后按 Enter: " -your_name = gets -# ... +your_name = gets -puts "(请替换成最后的答案)" \ No newline at end of file +puts "Hello, #{your_name}" From 5c4ddfef85b7b49682692bbb2045b7fae2609c9b Mon Sep 17 00:00:00 2001 From: RealAnalysis Date: Sat, 18 Apr 2020 23:54:02 +0800 Subject: [PATCH 2/3] 02 --- 02-variable.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/02-variable.rb b/02-variable.rb index a5a4753..d94a652 100644 --- a/02-variable.rb +++ b/02-variable.rb @@ -6,8 +6,11 @@ puts "a 是 #{a}" puts "b 是 #{b}" -# ... +c = a +a = b +b = c -puts "a 应该是 2,现在是 #{a}" -puts "b 应该是 1,现在是 #{b}" +puts "a \"应该\"是 2,现在是 #{a}" +puts "b \"应该\"是 1,现在是 #{b}" +# 这才是真正的学习了,什么叫 “ ’=’ 是赋值运算符(assignment operator),是指派右边的值到左边的变量” From 24b6f5431917e4d3c05cac5d080ea07b85ca2bb3 Mon Sep 17 00:00:00 2001 From: RealAnalysis Date: Mon, 20 Apr 2020 22:56:17 +0800 Subject: [PATCH 3/3] 04 --- 03-triangle.rb | 4 ++-- 04-pizzas.rb | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/03-triangle.rb b/03-triangle.rb index fafec03..00e3c5e 100644 --- a/03-triangle.rb +++ b/03-triangle.rb @@ -6,6 +6,6 @@ print "请输入直角三角形的底边,然后按 Enter: " b = gets -# ..... +c = a.to_f * b.to_f / 2 -puts "直角三角形的面积是: _________" \ No newline at end of file +puts "直角三角形的面积是: #{c}" diff --git a/04-pizzas.rb b/04-pizzas.rb index 4c2521f..d2c0cb4 100644 --- a/04-pizzas.rb +++ b/04-pizzas.rb @@ -6,7 +6,8 @@ print "请输入有多少人要吃,然后按 Enter: " people = gets -# ..... +a = pizzas.to_i +b = people.to_i -puts "每人可分得几片: _________ 片" -puts "还剩下几片: _________ 片" \ No newline at end of file +puts "每人可分得几片: #{a/b} 片" +puts "还剩下几片: #{a%b} 片"