VSC++=》 复制指定位置字符串 "

作者在 2020-03-13 20:00:53 发布以下内容



void 复制指定位置字符串(string a = "https://bbs.bccn.net/viewthread.php?tid=499735&extra=&page=1", int n = 47)
{
	string aa = ""; cout << a << ends << n << endl;
	if (n && n % strlen(a.data()))cout << (aa = a.substr(n - 1)) << ends << strlen(a.data()) << endl;
}


	复制指定位置字符串();
	string a = ""; int n = 0;
	cin >> a >> n;
	复制指定位置字符串(a, n);
    for (p = &str[m - 1]; p <= &str[n - 1]; p++)
        str1.push_back(*p);
int main(void)
{
    string str;
    void Partial_replication(string);
    cout<<"请输入一个字符串:"<<endl;
    cin>>str; 
    Partial_replication(str);
    return 0;
}
void Partial_replication(string str)
{
	int StringLength(string str);
	string str1 = str;
	int n, m, i = 0;
	char *p, *p1;
	n = StringLength(str);
	cout << "请输入被复制的字符个数m,(m<" << n << "):";
	cin >> m;
	for (p = &str[m - 1], p1 = &str1[0]; p <= &str[n - 1];)
		*p1++ = *p++;
	while(*p1)*p1++ = 0;
	cout << "被复制的部分字符串为:" << str1 << endl;
}
int StringLength(string str)
{
	char *p;
	int i = 0;
	for (p = &str[0]; *p != '\0'; p++)
		i++;
	return i;
}


无标题.png (上传于2020-03-13 20:00:53)
无标题.png


默认分类 | 阅读 2033 次
文章评论,共0条
游客请输入验证码