मैं तौलिया दिन भूल गया
दोनों उदाहरणों के लिए PHP स्क्रिप्ट (त्रुटि, स्ट्रिंग को स्वरूपित करना)
सही php स्क्रिप्ट, इनपुट स्व व्याख्यात्मक है
$argvविभिन्न परिणाम देखने के लिए अधिक इनपुट टिप्पणी / असहजता के साथ PHP स्क्रिप्ट
जैसा कि आप जानते हैं, 25 मई को तौलिया दिवस के रूप में जाना जाता है , क्योंकि बहुत से उपयोगों में एक तौलिया हो सकता है।
"द हिचहाइकर गाइड टू द गैलेक्सी" पुस्तक का एक सरल उद्धरण (व्यक्तिगत रूप से मैंने इस पुस्तक को "रोजमर्रा की मार्गदर्शिका" के रूप में लिया है ):
"एक तौलिया सबसे बड़े पैमाने पर उपयोगी चीज के बारे में है जो एक इंटरस्टेलर सहयात्री के पास हो सकता है। आंशिक रूप से इसका बहुत अच्छा मूल्य है।"
यदि आपको तौलिए के बारे में अधिक जानकारी की आवश्यकता है, तो इस SE.scifi उत्तर की जांच करें
चुनौती
उम्मीद है कि आप अपने पैरों के लिए कंबल के रूप में इस्तेमाल किए जाने वाले तौलिया के साथ ऐसा करेंगे।
किसी भी मान्य प्रोग्रामिंग भाषा में पूर्ण प्रोग्राम या फ़ंक्शन लिखें जो दो इनपुट लेता है
size Integer : #The size
message string : #A sentence
इन मूल्यों के साथ एक तौलिया कैसे खींचना है?
पहला प्रयोगsize :
आकार के इनपुट के आधार पर एक तौलिया खींचें, हमारे तौलिया के लिए एससीआई-कला
width = 12*size
#the line that has the "bar" its always present with different sizes
Width is defined as:
from the first | to the second | has to be equal to size*12 including both ||
<- width->
[===| |====]
| 12 chars || 1 height starts here, just after the "bar"
| SIZE = 1 || 2
| || 3 height = 5*size
| || 4
| || 5 height ends here just before the first line |=======|
|==========|| # the lines with the #
|==========|| # are always fixed
""""""""""""| # it means, every towel
| | # always has this 5 rows
"""""""""""" # no matter the size
दूसरा, इसे दे दो message
आपको इसे एक संदेश देना होगा, सुनहरा धागे में सिले एक सुंदर संदेश के बिना एक तौलिया क्या है?
उदाहरण 1
input: size=1, message="a simple message can stay with size"
width = 12*size
#the line that has the "bar" it's always present with different sizes
#no words allowed at the bar level
[===| |====]
| a simple || 1 height starts here, just after the "bar"
| message || 2
| can stay || 3 height = 5*size
| with size|| 4
| || 5 height ends here just before the first line |=======|
|==========|| # the lines with the #
|==========|| # are always fixed
""""""""""""| # it means, every towel
| | # always has this 5 rows
"""""""""""" # no matter the size
उदाहरण 2
input size=2
message="Don't Panic and bring a towel to SE Programming Puzzles and CodeGolf"
The size is 2
That means 24 width and 10 heigth
<- 24 chars width ->
[===| |====]
| Don't Panic and bring|| 1
| a towel to SE || 2
| Programming Puzzles || 3
| and CodeGolf || 4
| || 5
| || 6
| || 7
| || 8
| || 9
| || 10
|======================|| # The lines with the "#"
|======================|| # always present and
""""""""""""""""""""""""| # adapted to
| | # the towel width
"""""""""""""""""""""""" #
स्वीकृत मानदंड
- यह कोडगोल्फ है इसलिए सामान्य नियम लागू होते हैं।
नियम
आपको गारंटी दी जाती है कि सभी इनपुट स्ट्रिंग्स आकार में फिट होंगे, इसलिए कोई इनपुट पसंद नहीं है
size=1; message="This string is just tooooooooooooooooooooo long to fit the width and height of your towel"।स्ट्रिंग प्रारूप आपके ऊपर है, यदि आप उदाहरण के लिए सबस्ट्रिंग को केंद्र में रखना चाहते हैं।
शब्द-विराम विच्छेदित हैं।
संपादित करता
मुझे वास्तव में किसी भी उलझन के बारे में खेद है, क्योंकि ansii तौलिए मैं आकर्षित मापदंडों से मेल नहीं खाता था, आपके लिए अपेक्षित आउटपुट की जांच करने के लिए दोनों उदाहरणों के लिए एक PHP स्क्रिप्ट जोड़ा ।
साथ ही उन सभी लोगों को धन्यवाद, जिन्होंने मतदान किया और मेरी पहली चुनौती मानी: डी।
current line + next wordआपके तौलिया @Jakob के लिए अनुमत सीमा से अधिक हो जाएगी क्योंकि php स्क्रिप्ट मैंने इसे तय किया था।