Time Limit: 1 Sec Memory Limit: 2 MB
Submit: 14898 Solved: 7245
[Submit][Status]
Description
求一个字符串s中的第k个字符。
Input
输入一个串s和一个正整数k。s不为空串且长度不超过10。
Output
输出串s的第k个字符。
若k超过s的长度范围,输出“error”。
Sample Input
abc 1
Sample Output
a
HINT
Append Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main()
{
char
s[11];
int
k,i;
scanf
(
"%s %d"
,&s,&k);
int
len=
strlen
(s);
if
(k>len)
printf
(
"error"
);
else
printf
(
"%c"
,s[k-1]);
return
0;
}