3439 - 字符串长度

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

输入一个字符串,输出它长度。

题目输入

有多组测试数据

对于每组数据,每行输入一个字符串,长度不超过20

题目输出

输出每个字符串长度

输入/输出样例

输入格式

Helloworld
Hello world

输出格式

10
11

C语言解答

#include<stdio.h>
#include<string.h>
void main()
{
	char x[21];
	while((gets(x))!=NULL)
		printf("%d\n",strlen(x));
}

C++解答

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char a[100];
	while(gets(a) != NULL)
	{
		int m = strlen(a);
		cout << m << endl;
	}
}