PTA 7-264 求串长
分数 10
作者 usx程序设计类课程组
单位 绍兴文理学院
输入一个字符串(可能包含空格,长度不超过20),输出该串的长度。
输入格式:
输入在一行中给出1个长度不超过20的字符串s。
输出格式:
在一行中输出s的串长。
输入样例:
welcome to acm world
输出样例:
20
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB
#include <stdio.h>
#include <string.h>
int main(){
char s[100];
gets(s); //获取字符串
int lenth = strlen(s); //求字符串的长度
printf("%d\n", lenth);
return 0;
}
解题思路:
略
归属知识点:
数组
string.h头文件