标签:
输入一行字符串(字符个数不超过80),统计出该字符串的长度和字符串中出现的空格个数。
/* All rights reserved.
* 文件名称:test.cpp
* 作者:陈丹妮
* 完成日期:2015年 5 月 21 日
* 版 本 号:v1.0
*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
char a[81];
while(gets(a))
{
int l;
l=strlen(a);
cout<<l<<endl;
int i,n=0;
for(i=0; a[i]!='\0'; i++)
if(a[i]==' ')
n++;
cout<<n<<endl;
}
return 0;心得体会:加油!加油哦!刷刷刷!继续努力!!
标签:
原文地址:http://blog.csdn.net/nufangdongde/article/details/45898217