3-3 Product

来源:互联网 发布:监控软件行为 编辑:程序博客网 时间:2024/04/30 03:28
#include <stdio.h>#include <ctype.h>int main(){ char ch; int iNumber=0; long lProduct=1;  while((ch=getchar())!=EOF)    //Using getchar() {  if(isdigit(ch))         //Judge whether the char get from console is digit   {   iNumber=iNumber*10+ch-'0';  }  else if(' '==ch||'\n'==ch)    //If the char is not digit,then judge whether it is Space or Enter  {   lProduct*=iNumber;   iNumber=0;        //Let iNumber=0,for the next calculation  }  else            //If the char is not digt or Space or Enter,it must be other characters like letter,so let iNumber=1,  {             //because when we input other characters like letter,then iNumber will become 0,   iNumber=1;        //and everything will become 0.  } } printf("%ld\n",lProduct%1000);}


原创粉丝点击