#311. 字符串重复与连接

    ID: 311 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-2gesp3字符串循环结构

字符串重复与连接

字符串重复与连接

题目背景

题目描述

给定两个字符串 word 和一个分隔符 sep,返回一个由 countword 字符串组成的大字符串,它们之间用 sep 字符串分隔。

输入格式

输入包含一行字符串,表示 wordsep,它们之间由字面字符串 " " 分隔。

word" "sep

输出格式

输出一个字符串,该字符串由 countword 字符串组成,并由 sep 字符串分隔。

result_string

样例

Word" "X"
"WordXWordXWord"
This" "And"
"ThisAndThis"
This" "And"
"This"

样例解释

样例1中,word 是 "Word",sep 是 "X"。输出是 "WordXWordXWord",即 "Word" 重复3次,用 "X" 分隔。 样例2中,word 是 "This",sep 是 "And"。输出是 "ThisAndThis",即 "This" 重复2次,用 "And" 分隔。 样例3中,word 是 "This",sep 是 "And"。输出是 "This",即 "This" 重复1次。

数据范围

每个测试用例的时间限制为 1 秒,内存限制为 1024 KiB。