Date: Tue, 16 Nov 2004 23:37:38 +0800 (CST) From: Jianwei Rong <jianweirong@yahoo.com> To: ports@freebsd.org Cc: ports@freebsd.org Subject: Maybe a error Message-ID: <20041116153738.95792.qmail@web20225.mail.yahoo.com>
next in thread | raw e-mail | index | archive | help
--0-269919899-1100619458=:93942 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 8bit Content-Id: Content-Disposition: inline subject: Maybe a error Good afternoon, I found some display problem on running EX2-6-1.c in cce -e bash of FreeBSD4.10. Please try it yourself. Best Regards. rongjianwei 2004/11/15 *********************************************************** /* count digits, white space, others in input 对数字、分隔符(空格、制表符、换行符)和所有其他字符出现的次数进行计数 file name: EX2-6-1.c*/ #include <stdio.h> main() { int c, i, nwhite, nother; int ndigit[10]; //定义数组 nwhite = nother = 0; //计数器的初始值设为0。 for(i = 0; i<10; ++i) ndigit[i] = 0; while((c=getchar()) != EOF) if(c>'0' && c<='9') /* 操作符&&的含义是与。c为ASCII字符0到9之间, 就满足该if语句的条件*/ ++ndigit[c - '0']; //请复习ASCII码表。'0'表示0的ASCII码值。 else if(c==' ' || c=='\n' || c=='\t') ++nwhite; else ++nother; printf("digits=\n"); for(i = 0; i<10; ++i) printf("digit%d=%d\t", i, ndigit[i]); printf("\nwhite space = %d, \tother = %d \n", nwhite, nother); } ******************************************************* _________________________________________________________ Do You Yahoo!? 150万曲MP3疯狂搜,带您闯入音乐殿堂 http://cn.rd.yahoo.com/mail_cn/tag/yisou/music/*http://music.yisou.com/ 美女明星应有尽有,搜遍美图、艳图和酷图 http://cn.rd.yahoo.com/mail_cn/tag/yisou/image/*http://image.yisou.com 1G就是1000兆,雅虎电邮自助扩容! http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/ --0-269919899-1100619458=:93942 Content-Type: text/plain; name="EX2-6-1.c" Content-Description: EX2-6-1.c Content-Disposition: inline; filename="EX2-6-1.c" /* count digits, white space, others in input 对数字、分隔符(空格、制表符、换行符)和所有其他字符出现的次数进行计数 file name: EX2-6-1.c*/ #include <stdio.h> main() { int c, i, nwhite, nother; int ndigit[10]; //定义数组 nwhite = nother = 0; //计数器的初始值设为0。 for(i = 0; i<10; ++i) ndigit[i] = 0; while((c=getchar()) != EOF) if(c>'0' && c<='9') /* 操作符&&的含义是与。c为ASCII字符0到9之间, 就满足该if语句的条件*/ ++ndigit[c - '0']; //请复习ASCII码表。'0'表示0的ASCII码值。 else if(c==' ' || c=='\n' || c=='\t') ++nwhite; else ++nother; printf("digits=\n"); for(i = 0; i<10; ++i) printf("digit%d=%d\t", i, ndigit[i]); printf("\nwhite space = %d, \tother = %d \n", nwhite, nother); } --0-269919899-1100619458=:93942--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041116153738.95792.qmail>