游客 Signup | Login
中文 | En

1452 - C语言-子串

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

Input

数字n 一行字符串 数字m

Output

从m开始的子串

Examples

Input

6
abcdef
3

Output

cdef

Solution C

#include<stdio.h>
int main()
{
    char c[100];
    int a,b;
    scanf("%d",&a);
    char x=getchar();
    gets(c);
    scanf("%d",&b);
    for(int i=b-1;c[i]!='\0';i++)
        printf("%c",c[i]);
}

Solution C++

#include<cstdio>
int main()
{
	int n,t;
	char *r;
	while(scanf("%d",&n)!=-1)
	{
		r=new char[n+2];
		while(gets(r)&&r[0]=='\0');
		scanf("%d",&t);
		if(t<n)
			printf("%s",r+t-1);
		printf("\n");
		delete r;
	}
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题