c语言的问题

[复制链接]
查看11 | 回复2 | 2008-11-26 01:01:28 | 显示全部楼层 |阅读模式
填空题。
#include
#include
void main()
{
char str[81],*p;
int wordnum=0;
printf("Please input an English sentens:");
gets(str);
puts(str);
p=str;
while(*p==32)
[]
while(*P!='\0')
{
do

p++;
while([](*p==''||*p=='\0'));
wordnum++;
while(*p==32)
p++;
}
printf("These are%d word in the line\n",wordnum);
}
- -这个是题目。。不要改变程序啊。。。。。。不要删行和加行啊!

回复

使用道具 举报

千问 | 2008-11-26 01:01:28 | 显示全部楼层
第一个空填:p++; 第二个空填:! 楼主这个程序写的不错,比较简练。但是你的有些地方写错,主要是英文单词: sentens-->sentence These...word-->There...words while([](*p==''||*p=='\0')); -->while([](*p==' '||*p=='\0')); 是空格字符' ',不是空着。 原程序改动后在win-tc和Dev-c++下运行通过,执行正确。 #include#include#includevoid main() { char str[81],*p; ...
回复

使用道具 举报

千问 | 2008-11-26 01:01:28 | 显示全部楼层
小编了一个,但是此程序的局限性大。#include#includevoid main(){char str[81],*p,*q;int wordnum=0;printf("Please input an English sentens:");gets(str);puts(str);...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行