编写一个程序,它使用一个char数组和循环来每次读取一个单词,知道用户输入done为止.随后程序指出输入 了多少单词,不

编写一个程序,它使用一个char数组和循环来每次读取一个单词,知道用户输入done为止.随后程序指出输入 了多少单词,不包括done,下面是运行情况:
Enter words(type done to stop)
Today is a sunny day done,isn't it?
You entered a total of 5 words
您应该在程序中包含头文件cstring,并使用strcmp()来进行比较测试
一个打火机100元 1年前 已收到1个回答 举报

黑三公子 幼苗

共回答了18个问题采纳率:94.4% 举报

#include
void main()
{
int i,words=0;
char a[99],str[99];
for(i=0;;i++)
{
a[i]=cin.get();
str[i]=a[i];
if(a[i]==' ') words++;
if(a[i]=='e'&&a[i-1]=='n'&&a[i-2]=='o'&&a[i-3]=='d'){str[i-3]='';break;}
}
cout<<"You entered atotal of "<}

1年前 追问

11

一个打火机100元 举报

һҪstrcmp()ôأ

举报 黑三公子

strcmp()DZȽַò
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.015 s. - webmaster@yulucn.com