正在加载图片...
例如:输入一个句子,统计单词个数。 首先编写一个头文件: if (iswhite(strid==TRUE) /* hong. h米/ n #include <stdio. h> printf(whas %d words", n) #define true 1 #define false o 然后,编写程序,其中 包含该头文件: int iswhite(char c) #include"a: hong. h if(c=c='\n'c='\t') main return TRUE fint i, n=0 e⊥se char str[80] return FALSE; gets(str for(i=1; strli]!=\0' i++)例如:输入一个句子,统计单词个数。 首先编写一个头文件: /*hong.h*/ #include <stdio.h> #define TRUE 1 #define FALSE 0 然后,编写程序,其中 包含该头文件: #include "a:\hong.h" main() {int i,n=0; char str[80]; gets(str); for(i=1;str[i]!='\0';i++) if (iswhite(str[i])==TRUE) n++; printf(“has %d words",n); } int iswhite(char c) { if(c==''||c=='\n'||c=='\t') return TRUE; else return FALSE;}
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有