以下是完整的D语言实现代码:

import std.stdio; import std.string;

void main() { string input = "a nice title uses the correct case"; string[] words = input.split(" ");

foreach (i, word; words) {
    words[i] = word.capitalize();
}

string output = words.join(" ");
writeln(output);

}

输出结果为: A Nice Title Uses The Correct Case

dlang语言实现将一个字符串中的每个单词首字母大写有点类似php的以下常用代码use IlluminateSupportStr;$converted = Strtitlea nice title uses the correct case; A Nice Title Uses The Correct Case给出完整可以运行的d语言实现代码

原文地址: http://www.cveoy.top/t/topic/fmXF 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录