游客 Signup | Login
中文 | En

1340 - C语言程序设计教程(第三版)课后习题10.7

有一字符串,包含n个字符。写一函数cpystr,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串。

Input

数字n 一行字符串数字m

Output

从m开始的子串

Examples

Input

6
abcdef
3

Output

cdef

Solution C++

#include<iostream>
using namespace std;
char from[100],to[100];
void solve(char *p,int n,char *q)
{
	p+=n-1;
	while (*q++=*p++) ;
}
int main()
{
	int n,m;
	cin>>n;
	for (int i=0; i<n; i++) cin>>from[i];
	cin>>m;
	solve(from,m,to);
	cout<<to<<endl;
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题