Nav: << previous: 194.转置文件 | next: 196.删除重复的电子邮箱 >>
Description
tab: English
<p>Given a text file <code>file.txt</code>, print just the 10th line of the file.</p>
<p><strong class="example">Example:</strong></p>
<p>Assume that <code>file.txt</code> has the following content:</p>
<pre>
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
</pre>
<p>Your script should output the tenth line, which is:</p>
<pre>
Line 10
</pre>
<div class="spoilers"><b>Note:</b><br />
1. If the file contains less than 10 lines, what should you output?<br />
2. There's at least three different solutions. Try to explore all possibilities.</div>
---
[submissions](https://leetcode.com/problems/tenth-line/submissions/) | [solutions](https://leetcode.com/problems/tenth-line/solutions/)
tab: 中文
<p>给定一个文本文件 <code>file.txt</code>,请只打印这个文件中的第十行。</p>
<p><strong>示例:</strong></p>
<p>假设 <code>file.txt</code> 有如下内容:</p>
<pre>Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
</pre>
<p>你的脚本应当显示第十行:</p>
<pre>Line 10
</pre>
<p><strong>说明:</strong><br>
1. 如果文件少于十行,你应当输出什么?<br>
2. 至少有三种不同的解法,请尝试尽可能多的方法来解题。</p>
---
[提交记录](https://leetcode.cn/problems/tenth-line/submissions/) | [题解](https://leetcode.cn/problems/tenth-line/solution/)
Solutions & Notes
properties:
note.updated:
displayName: Last Updated
note.relative_links:
displayName: Related Links
note.desc:
displayName: Description
note.grade:
displayName: Rating
note.program_language:
displayName: Language
note.time_complexity:
displayName: TC
note.space_complexity:
displayName: SC
views:
- type: table
name: Solutions & Notes
filters:
and:
- file.hasLink(this.file)
- file.tags.containsAny("leetcode/solution", "leetcode/note")
order:
- file.name
- desc
- program_language
- time_complexity
- space_complexity
- grade
- relative_links
- updated
sort:
- property: grade
direction: ASC
- property: time_complexity
direction: ASC
- property: program_language
direction: ASC
columnSize:
file.name: 104
note.space_complexity: 65
note.grade: 126
Similar Problems
properties:
note.lcTopics:
displayName: Topics
note.lcAcRate:
displayName: AC Rate
note.favorites:
displayName: Favorites
note.grade:
displayName: Rating
note.translatedTitle:
displayName: Title (CN)
note.lcDifficulty:
displayName: Difficulty
views:
- type: table
name: Similar Problems
filters:
and:
- file.hasLink(this.file)
- similarQuestions.contains(this.file)
order:
- file.name
- translatedTitle
- lcTopics
- lcDifficulty
- lcAcRate
- grade
- favorites
sort:
- property: file.name
direction: ASC
- property: lcTopics
direction: DESC
columnSize:
note.translatedTitle: 240
note.lcTopics: 347
note.lcAcRate: 75
note.grade: 122