早教吧 育儿知识 作业答案 考试题库 百科 知识分享

WriteaC++programtocountthenumberoftimesthewords"worldoccurinthekeyboardinput.Youmayassumetheinputwillcontainonlywordsseparatedbywhitespace(i.e.,nopunctuationappears).

题目详情
Write a C++ program to count the number of times the words "world
occur in the keyboard input.You may assume the input will
contain only words separated by whitespace (i.e.,no punctuation appears).
▼优质解答
答案和解析
使用 strstr(const char *s1,const char *s2) 此函数,扫描S1,找出S2字符串第一次出现在S1的位置头文件 #include主要算法:char s1[100],s2[10];char *p=s1;int count=0;gets(s1);s2=""world;while(1){p=strstr(p,s2)...