酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

输入一个正整数 repeat (0<repeat<10),做 repeat 次下列运算: 输入一个字符串 t 和一个正整数 m,将字符串 t 中从第 m 个字符开始的全部字符复制到字符串 s 中,再输出字符串 s。 要求定义并调用函数 strmcpy(s,t,m), 它的功能是将字符串 t 中从第 m 个字符开始的全部字符复制到字符串 s 中,函数形参s和t的类型是字符指针,形参m的类型是int,函数类型是void。

```cpp #include <iostream> #include <cstring> void strmcpy(char* s, const char* t, int m) { strcpy(s, t + m - 1); } int main() { int repeat; std::cin >> repeat; for (int i = 0; i < repeat; i++) { char s[100], t[100]; int m; std::cin >> t >> m; strmcpy(s, t, m); std::cout << s << std::endl; } return 0; } ``` [2024-11-30 13:34:49 | AI写代码神器 | 254点数解答]

相关提问