- 博客(6)
- 收藏
- 关注
原创 1.6 1-13,1-14
1-13pseudocode:read a word , EOF to stopif the word is ' ' or '/t' or '/n'if the pre state is INpush count to a[i]add i oncecount=0if the word is not a ' ' and '/t' and '/n'if the pre state is OUTupdate the state to INadd count onceupdate lasts to state#in
2011-03-28 10:01:00
216
转载 Difference between pointer and array
Can anybody tell me difference between the bellow statements?char *p = "This is test";char a[] = "This is test";ANS:When you declare char p[] you are declaring an array of chars (which is accessible to be both read and written), and this array is init
2011-03-24 23:30:00
304
原创 1-5.4Word Counting (1-11 ,1-12)
1-11Ques:How do you test the word count program? What kinds of input are most likely to uncover bugs if there are any?Ans:I use a state "IN" or "OUT" to represent the char receiving now is in a word or not, a count for counting words,and a flag stores last
2011-03-24 20:02:00
325
原创 1-5.3 Line Counting (1-8, 1-9, 1-10)
1-8:Write a program to count blanks, tabs, and newlines#include int main(){ int c; int i=j=k=0; while(c=getchar()!=EOF) { if(c==' ')//or if(c==0x20) i++; if(c=='/t') j++; if(c=='/n')
2011-03-21 22:11:00
291
原创 literal constants
字符常量包含一个或多个字符,周围使用单引号围起来,如:‘a’ 'xy' '0'但是也需要注意某些特殊的字符是例外:单引号(‘),反斜线(/),双引号(”)等单引号: /' 双引号: /"问号: /?反斜线: //“/x”是十六进制的意思,后面跟十六进制的数字字符“/o、/oo、/ooo”(o为任意一个八进制字符),代表八进制的字符
2011-03-21 20:50:00
572
原创 位图算法(编程珠玑例题)
输入:一个最多包含n个正整数的文件,最大不超过一千万,每个数最多只出现一次,数据之间没有明显的关联输出:升序排列的整数列表要求:只有大约1MB的内存可用,磁盘空间充足,运行时间最多不超过1分钟,10秒左右就可以不需要优化分析:1MB的内存只能存储大约250000个int型整数,远远低于1千万的要求,但是每个int型整数有32位,如果用第i位的0,1来表示数据i的存在与否,一千万的整数需要1000 0000/32=312500个整数,他们将占有312500*4=1250000个比特,即大约1.2MB的内存#i
2011-03-15 23:26:00
990
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人