7-48 字符串输入练习 (I) (15 分)
计算字符串的长度。
输入格式:
每行一个字符串。
输出格式:
针对每行字符串,输出该串的长度。
输入样例:
1. hello world! 2. welcome to acm world
结尾无空行
输出样例:
在这里给出相应的输出。例如:
1. 12 2. 20
结尾无空行
#include<iostream> using namespace std; int main(){ string s; while(getline(cin,s)){ cout<<s.size()<<endl; } return 0; }