《数据结构》实验四: 字符串和多维数组 实验
发布时间:2020-12-15 05:50:41 所属栏目:安全 来源:网络整理
导读:#includeiostream #includecstring using namespace std; int main() { int count,state; char *p; count=0; state=1; char s[50]; cout"请输入文本"endl; cin.get(s,50); p=s; while(*p!=' ') { if(*p==' ') state=1; else if(state==1) { state=0; count+
#include<iostream> #include<cstring> using namespace std; int main() { int count,state; char *p; count=0; state=1; char s[50]; cout<<"请输入文本"<<endl; cin.get(s,50); p=s; while(*p!=' ') { if(*p==' ') state=1; else if(state==1) { state=0; count++; } p++; } cout<<"单词数是"<<count<<endl; return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |