> 其他 >
编写一个程序,它使用一个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()来进行比较测试
人气:494 ℃ 时间:2020-05-11 15:38:16
解答
#include<iostream.h>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...����һ�����Ҫ��strcmp()����ô���أ�strcmp()�DZȽ��ַ��ò���
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版