您好,D语言中并没有内置的reverse函数。如果您想要将字符串反转,可以使用std.algorithm中的reverse函数,代码如下:

import std.algorithm; import std.datetime; import std.stdio; import std.string;

void main() { string str = "hello world"; auto s = Clock.currTime;

for (int i = 0; i < 1000000; i++)
{
    str = replace(str, "world", "dlang");
    str = str.retro; // 反转字符串
}

auto d = Clock.currTime;
writeln("Replace time: ", d - s, " ticks");

}

d语言以下代码提示reverse不存在帮我修复import stddatetime;2import stdstdio;3import stdstring;45void main67 string str = hello world;8 auto s=ClockcurrTime;9 1011 for int i = 0; i 1000000; i++12 13

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

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