下载此文档

图灵俱乐部第六期C语言基础.pptx


文档分类:IT计算机 | 页数:约40页 举报非法文档有奖
1/40
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/40 下载此文档
文档列表 文档介绍
图灵俱乐部第六期C语言基础TypeConversionsAcharisjustasmallinteger举个栗子1/*atoi:convertstointeger*/intatoi(chars[]){ inti,n; n=0; for(i=0;s[i]>='0'&&s[i]<='9';++i)n=10*n+(s[i]-'0');returnn;}TypeConversions举个栗子2/*lower:convertctolowercase;ASCIIonly*/intlower(intc){ if(c>='A'&&c<='Z') returnc+'a'-'A';elsereturnc;}TypeConversionsThestandardheader<>,,ifanoperatorlike+or*thattakestwooperands(abinaryoperator)hasoperandsofdifferenttypes,the“lower”typeispromotedtothe“higher”,,ifeitheroperandisdouble,,ifeitheroperandisfloat,,,ifeitheroperandislong,!Floatsinanexpressionarenotautomaticallyconvertedtodouble;Ingeneral,mathematicalfunctionslikethosein<>,or,lessoften,tosavetimeonmachineswheredouble-:-1L<1U,because1U,whichisanunsignedint,-1L>1UL,because-,explicittypeconversionscanbeforced(“coerced”)inanyexpression,:(type-name)expressionTypeConversions举个栗子3unsignedlongintnext=1;/*rand:returnpseudo-randomintegeron0..32767*/intrand(void){ next=next***********+12345; return(unsignedint)(next/65536)%32768;}/*srand:setseedforrand()*/vooidsrand(unsignedintseed){ next=seed;}

图灵俱乐部第六期C语言基础 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数40
  • 收藏数0 收藏
  • 顶次数0
  • 上传人fr520520
  • 文件大小2.46 MB
  • 时间2019-06-03