Maybe a error
Jianwei Rong
jianweirong at yahoo.com
Tue Nov 16 07:37:39 PST 2004
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/
-------------- next part --------------
/* 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);
}
More information about the freebsd-ports
mailing list