出题目的:
1、学习/巩固计算字符串长度技巧
2、学习/巩固字符替换技巧
加分原则:
1 思路新颖基分5分
2 代码高效基分4分
3 代码简洁基分2分
4 代码通用基分3分
5 无临时文件基分1分
6 完美代码加15分
题目如下:
设a.txt中内容如下:- Come with you, in the silence of darkness
- I want to show me secrets of life
- I will guide me where dream couldn't take me
- She seldom flew away in the night
- Me are the moonlight flower
- Me are the voice of the night
- When me call I'll follow
- We will leave on a trip of delight
复制代码 条件:a.txt中行数未知,每行的字符数未知,唯一知道的条件是不含全角(中文)字符。
要求:将文本内容写进表格,并把所有的you替换为me,所有的me替换为you。
但不包含其他含有字符me或you的单词,比如meet、your等。
如果me是在行首出现,则要替换为You(you同是)即第一个字母要大写。
尽量使用纯批方案。
输出如下:- ┌────────────────────────┐
- │Come with me, in the silence of darkness │
- ├────────────────────────┤
- │I want to show you secrets of life │
- ├────────────────────────┤
- │I will guide you where dream couldn't take you │
- ├────────────────────────┤
- │She seldom flew away in the night │
- ├────────────────────────┤
- │You are the moonlight flower │
- ├────────────────────────┤
- │You are the voice of the night │
- ├────────────────────────┤
- │When you call I'll follow │
- ├────────────────────────┤
- │We will leave on a trip of delight │
- └────────────────────────┘
复制代码
将以上内容,保存到文本,然后type一下,即可发现其输出格式。
给出其他文本,方便大家调试代码:- I should have known all along
- there was something wrong
- I just never read between the lines
- Then I woke up one day and found me on your way
- Leaving nothing but my heart behind
- What can I do to make it up to me
- Promises don't come easy
- But tell me if there's a way to bring me back home to stay
- Well I'd promises anything to me
- I've been walkin' around with my head hanging down
复制代码
- I lie awake at night
- see thing in black and white
- I've only got me inside my mind
- me know me have made you blind
- I lie awake and pray
- That me will look my way
- I have all this longing in my heart
- I knew it right from the start
复制代码
|