64,636
社区成员
发帖
与我相关
我的任务
分享
//楼主你的意思是这个吗?
#include <stdio.h>
#include <string.h>
int main()
{
char src[] = "我爱CSDN程序员之家"; //我不支持中文输入
//scanf("%c", src);
char *psrc = src;
size_t occurs = 0;
while (*psrc)
{
if ((unsigned char)*psrc > 0x80)
{
++occurs;
}
++psrc;
}
int different = strlen(src) - occurs;
printf("中文单词个数: %d\n", occurs / 2);
printf("英文单词个数: %d\n", different);
return 0;
}
#include <iostream>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
void main()
{
string line,word;
vector <string> vec;
while(getline(cin,line))
{
istringstream in(line);
while(in>>word)
vec.push_back(word);
}
cout<<vec.size()<<endl;
}
i love you
you love me
^Z
6
请按任意键继续. . .