摘要: 我的答案:照抄此程序 ,观察运行结果,来测试!初步的测试,nl 即 行数的统计会出现错误,按照\n来计算行数 出容易算少一行,,当我在最后一行的时候 以EOF结束的话,此行将没有计算在内。没有理解好题目,程序并没有错,题目的意思是想让我知道如何的去测试一个程序可能出现的错误!答案:满足边界条件的输入情况, 最有助于发现单词计数程序中的错误......省略顺便把此程序贴上#include #define IN 1#define OUT 0int main(){ int c, nl, nw, nc, state; state = OUT; nl = nw = nc = 0; ... 阅读全文
posted @ 2013-10-18 20:03 _Jango 阅读(2104) 评论(0) 推荐(0) 编辑
摘要: #include int main(){ int c; while((c = getchar()) != EOF) { if(c == '\t') printf("\\t"); if(c == '\b') printf("\\b"); if(c == '\\') printf("\\\\"); if(c != '\t') if(c != '\b') if(c != '\\') putchar(c); }}照搬答案...自己思路太过复杂..没 阅读全文
posted @ 2013-10-18 19:19 _Jango 阅读(1062) 评论(1) 推荐(0) 编辑
摘要: #include #define NONBLANK 'a'int main(){int c, lastc;lastc = NONBLANK;while((c = getchar()) != EOF){ if(c != ' ') putchar(c); if(c == ' ') if (lastc != ' ') putchar(c); lastc = c;}}照搬书上的答案...具体的内涵还没搞懂。 阅读全文
posted @ 2013-10-18 18:18 _Jango 阅读(281) 评论(0) 推荐(0) 编辑
摘要: Test 1-1 运行“hello world ”程序#include int main(){ printf("Hello world!\n");}去掉字符串,int不会报错,,,去掉其余的标点,函数名会报错。Test 1-2 #include int main(){ printf("Hello world!\n\c");}output: Hello world !cTest 1-3#include int main(){ float fahr, celsius; int lower, upper, step; lower = 0; upper = 30 阅读全文
posted @ 2013-10-18 18:12 _Jango 阅读(396) 评论(0) 推荐(0) 编辑