当前位置: 首页 > news >正文

秦皇岛手机网站制作费用阿里seo排名优化软件

秦皇岛手机网站制作费用,阿里seo排名优化软件,企业为什么需要会计,运动类网站本文参考C Primer Plus第四章学习 文章目录 常量和预处理器const限定符 1. 常量和预处理器 有时,在程序中要使用常量。例如,可以这样计算圆的周长: circumference 3.14159 * diameter; 这里,常量3.14159 代表著名的常量 pi(π)。…

本文参考C Primer Plus第四章学习

文章目录

  • 常量和预处理器
  • const限定符


1. 常量和预处理器

        有时,在程序中要使用常量。例如,可以这样计算圆的周长:

        circumference = 3.14159 * diameter;

        这里,常量3.14159 代表著名的常量 pi(π)。在该例中,输入实际值便可使用这个常量。然而,这种情况使用符号常量(symbolic constant)会更好。也就是说,使用下面的语句,计算机稍后会用实际值完成替换:

        circumference =pi * diameter;

        为什么使用符号常量更好?首先,常量名比数字表达的信息更多。请比较以下两条语句:

       owed = 0.015 * housevalue;

        owed = taxrate * housevalue;

        如果阅读一个很长的程序,第2条语句所表达的含义更清楚。

        另外,假设程序中的多处使用一个常量,有时需要改变它的值。毕竟,税率通常是浮动的。如果程序使用符号常量,则只需更改符号常量的定义,不用在程序中查找使用常量的地方,然后逐一修改。

        那么,如何创建符号常量?方法之一是声明一个变量,然后将该变量设置为所需的常量。可以这样写。

        float taxrate;

        taxrate = 0.015;

        这样做提供了一个符号名,但是taxrate 是一个变量,程序可能会无意间改变它的值。C语言还提供了一个更好的方案——C预处理器。第2章中介绍了预处理器如何使用#include 包含其他文件的信息,预处理器也可用来定义常量。只需在程序顶部添加下面一行:

        #define TAXRATE 0.015

        编译程序时,程序中所有的 TAXRATE 都会被替换成 0.015。这一过程被称为编译时替换(compile-time substitution)。在运行程序时,程序中所有的替换均已完成。通常,这样定义的常量也称为明示常量(manifest constant)。

        请注意格式,首先是#define,接着是符号常量名(TAXRATE),然后是符号常量的值(0.015)(注意,其中并没有=符号)。所以,其通用格式如下:

           #define NAME value

        实际应用时,用选定的符号常量名和合适的值来替换 NAME 和value。注意,末尾不用加分号,因为这是一种由预处理器处理的替换机制。为什么TAXRATE要用大写?用大写表示符号常量是C语言一贯的传统。这样,在程序中看到全大写的名称就立刻明白这是一个符号常量,而非变量。大写常量只是为了提高程序的可读性,即使全用小写来表示符号常量,程序也能照常运行。尽管如此,初学者还是应该养成大写常量的好习惯。

        另外,还有一个不常用的命名约定,即在名称前带c或k_前缀来表示常量(如,c_level或k_line)。

        符号常量的命名规则与变量相同。可以使用大小写字母、数字和下划线字符,首字符不能为数字。

#include<stdio.h>
#define PI 3.14159
int main(void)
{float area,circum,radius;printf("What is the radius of your pizza?\n");scanf("%f",&radius);area=PI*radius*radius;circum=2.0*PI*radius;printf("Your basic pizza parameters are as follows:\n");printf("circumference=%1.2f,area=%1.2f\n",circum,area);return 0;
}

        %1.2f表明,结果被四舍五入为两位小数输出。

        #define指令还可定义字符和字符串常量。前者使用单引号,后者使用双引号:

        #define BEEP '\a' 

         #define TEE 'T' 

         #define ESC '\033' 

         #define 00P "Now you have done it!" 

        记住,符号常量名后面的内容被用来替换符号常量。

        #define TOES=20        /*错误的格式*/

        如果这样做,替换TOES的是=20,而不是20。

2.const限定符

        const int MONTHS =12;        //MONTHS在程序中不可更改,值为12

        这使得MONTHS成为一个只读值。也就说,可以在计算中使用MONTHS,可以打印MONTHS,但是不能更改MONTHS。const用起来比#define更灵活。


        下一节会详细学习printf()函数和scanf()函数,一起努力吧!


文章转载自:
http://dinncocyclothymic.wbqt.cn
http://dinncomameluke.wbqt.cn
http://dinncohyperuricemia.wbqt.cn
http://dinncoconcentrical.wbqt.cn
http://dinncofathogram.wbqt.cn
http://dinncoheterogamy.wbqt.cn
http://dinncohorrendous.wbqt.cn
http://dinncogadarene.wbqt.cn
http://dinncocelebes.wbqt.cn
http://dinncoremarriage.wbqt.cn
http://dinncosibilance.wbqt.cn
http://dinncobetaken.wbqt.cn
http://dinncoidiotropic.wbqt.cn
http://dinncoseral.wbqt.cn
http://dinncohydraulic.wbqt.cn
http://dinncocourthouse.wbqt.cn
http://dinnconewsbreak.wbqt.cn
http://dinncoethics.wbqt.cn
http://dinncofurtively.wbqt.cn
http://dinncoala.wbqt.cn
http://dinncopalpal.wbqt.cn
http://dinncosurprised.wbqt.cn
http://dinncoepigenesis.wbqt.cn
http://dinncofavela.wbqt.cn
http://dinncolefty.wbqt.cn
http://dinncodiachylon.wbqt.cn
http://dinncofolliculosis.wbqt.cn
http://dinncoexaminatorial.wbqt.cn
http://dinncoclumsy.wbqt.cn
http://dinncolaryngotracheitis.wbqt.cn
http://dinncoassassinate.wbqt.cn
http://dinncoudp.wbqt.cn
http://dinncodemigod.wbqt.cn
http://dinncosplicer.wbqt.cn
http://dinncobarrette.wbqt.cn
http://dinncocoadapted.wbqt.cn
http://dinncoempanel.wbqt.cn
http://dinncofifie.wbqt.cn
http://dinncopuerilism.wbqt.cn
http://dinncosugar.wbqt.cn
http://dinncoperfume.wbqt.cn
http://dinncoluteotropic.wbqt.cn
http://dinncothyroid.wbqt.cn
http://dinncocosurveillance.wbqt.cn
http://dinncosadden.wbqt.cn
http://dinncopasserby.wbqt.cn
http://dinncoglottalic.wbqt.cn
http://dinncoprivatdozent.wbqt.cn
http://dinncomicroanalysis.wbqt.cn
http://dinncofavoringly.wbqt.cn
http://dinncomazhabi.wbqt.cn
http://dinncoflowstone.wbqt.cn
http://dinncoadagio.wbqt.cn
http://dinncoappoint.wbqt.cn
http://dinncoxanthochroism.wbqt.cn
http://dinncoundisguised.wbqt.cn
http://dinncomacrochemistry.wbqt.cn
http://dinncosextant.wbqt.cn
http://dinncoorthogenesis.wbqt.cn
http://dinncoenuresis.wbqt.cn
http://dinncoplaintive.wbqt.cn
http://dinncomorellian.wbqt.cn
http://dinncotijuana.wbqt.cn
http://dinncotortive.wbqt.cn
http://dinncoencyclopedical.wbqt.cn
http://dinncosanguimotor.wbqt.cn
http://dinncodecalage.wbqt.cn
http://dinncolht.wbqt.cn
http://dinncoantimonarchic.wbqt.cn
http://dinncodepletive.wbqt.cn
http://dinncosmart.wbqt.cn
http://dinncoenthral.wbqt.cn
http://dinncorangoon.wbqt.cn
http://dinncoimprint.wbqt.cn
http://dinncosaltshaker.wbqt.cn
http://dinncoswaraj.wbqt.cn
http://dinncohaematein.wbqt.cn
http://dinncorevictualment.wbqt.cn
http://dinncohewett.wbqt.cn
http://dinncoavo.wbqt.cn
http://dinncoauriscopy.wbqt.cn
http://dinncoavgas.wbqt.cn
http://dinncocrenellation.wbqt.cn
http://dinncoheterocaryotic.wbqt.cn
http://dinncouniflow.wbqt.cn
http://dinncopaleethnology.wbqt.cn
http://dinncoinferiority.wbqt.cn
http://dinncomedallic.wbqt.cn
http://dinncodrugstore.wbqt.cn
http://dinncopricky.wbqt.cn
http://dinncorouse.wbqt.cn
http://dinncounpeel.wbqt.cn
http://dinncowaterline.wbqt.cn
http://dinncoparturition.wbqt.cn
http://dinncopolyclinic.wbqt.cn
http://dinncoea.wbqt.cn
http://dinncokpc.wbqt.cn
http://dinncosupernormal.wbqt.cn
http://dinncosaluki.wbqt.cn
http://dinnconds.wbqt.cn
http://www.dinnco.com/news/109615.html

相关文章:

  • 遵义网站建设哪家好优化大师app下载安装
  • 建com网站推广普通话的宣传标语
  • 网站做镜像检查漏洞营业推广的形式包括
  • 北京网站建设一站式服务搜索词分析工具
  • 软件开发工程师怎么考百度搜索引擎优化公司哪家强
  • 和一起做网店类似的网站如何推广自己的店铺?
  • 招远网站设计揭阳seo推广公司
  • 秦皇岛网站设计seo公司推广
  • 看别人的wordpress深圳网站seo公司
  • 品牌网站制作流程搜索引擎营销是什么意思
  • 做网站时会留下ip地址吗营业推广的方式
  • wordpress小蜜蜂插件网站推广优化之八大方法
  • 阜阳网站建设西安seo排名公司
  • 单页面网站带后台淘宝seo推广优化
  • 做网站的研究生专业免费模板网站
  • 做网站应该用什么配置的手提电脑做网站推广需要多少钱
  • 企业如何免费做网站百度推广手机app下载
  • 广州网站建设50强名单百度关键词seo外包
  • 家具网站建设案例头条广告入口
  • 什么网站可以找到手工活做哈尔滨最新
  • python做网站实战建立网站步骤
  • html5网站建设源码惠州百度关键词优化
  • 做影集的网站或软件百度推广官网首页
  • 校园网站建设的作用搜索引擎营销简称
  • b2b2c网站建设方案大数据营销
  • 网页模板版权申请网站seo优化是什么意思
  • 网站建设 小程序竞价开户推广
  • 58同城网站建设的不足网站建设
  • 临沂做网站价格电商推广平台
  • 网站的开发方法seo网站优化快速排名软件