Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
2012/11/16 問題1
Search
mizti
November 18, 2012
550
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
2012/11/16 問題1
mizti
November 18, 2012
More Decks by mizti
See All by mizti
CutSticks.pdf
mizti
0
660
Maze Maker
mizti
0
630
「銀将ご乱心」
mizti
0
990
paint.pdf
mizti
1
650
kaibun.pdf
mizti
0
660
dfs1.pdf
mizti
0
610
問題1. 解答例
mizti
0
510
Featured
See All Featured
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Raft: Consensus for Rubyists
vanstee
142
7.8k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
540
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
Un-Boring Meetings
codingconduct
0
460
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
330
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
Transcript
問題1.ポーの惑星 イントロダクション イントロダクション イントロダクション イントロダクション: あなたがある朝目覚めるとあなたは見知らぬ惑星にいました。この惑星では四 則演算の書き方が地球とは異なるようです。 地球で 3 +
6 と書くはずのところでは (+ 3 6)と演算子を最初に書いて、それを( ) で括るようです。 また、9 – ( 2 + 1) は (- 9 (+ 2 1 ) ) となるようです。 この惑星の科学者やビジネスマンは長い長い式の計算に日々追い立てられ、苦 しんでいるようでした。 あなたはPCを持ったままこの惑星に来たようです。せっかくなのでこの惑星の人 たちのために、式の自動的に計算を行なってあげるプログラムを作ってあげま しょう。
問題1.ポーの惑星 • Input: 入力は以下のような形式の一行のテキストからなる式です。 • 数字 • + - *
の3種類の演算子 • ( ) および半角スペース から構成され、以下のように記述されています。 ( + 4 9 ) あるいは ( - 9 (+ 11 300)) すなわち、式は(演算子 式または数字 式または数字) という方法で記載されてい ます。 数字は-1000から1000の間であり、数字と数字の間、数字と演算子は1文字以 上の半角スペースで分かたれています。カッコと数字の間、カッコとカッコの間は スペースで区切られているとは限りません。 • Output: 各入力に対し,計算の結果を1行に出力してください。 それ以外の余計な文字を 含んではいけません。答えが負数であることはあり得ます。
問題1.ポーの惑星 Sample Input: (+ 6 8) Sample Output: 14 Sample
Input: (+ 5 (- 8 3)) Sample Output: 10 Sample Input: (+ (* (- 9 4) 8) (- 8 3)) Sample Output: 45 Sample Input: (* (- 9 20) (+ 7 (- 999 108)) ) Sample Output: -9878 できたら、
[email protected]
まで送付お願いします。 実行イメージ # cat input.txt (- 8 3) # cat input.txt | ruby a.rb 5 標準入力はRubyなら STDIN.gets.chomp などで拾えます。 (STDIN.getsは改行コードが 入ってしまうためchompが必要)