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

网站建设制作做网站优化推广公司每天新闻早知道

网站建设制作做网站优化推广公司,每天新闻早知道,wordpress筛选最新文章,数字营销工具1.7 C语言之函数概述 一、概述二、练习 一、概述 函数就是把一组计算操作封装起来,供程序员调用,我们只需知道其提供了什么功能,而无需关注具体实现细节(前提是其久经考验,设计没有问题,后续我们自己写的函数大概率还…

1.7 C语言之函数概述

  • 一、概述
  • 二、练习

一、概述

函数就是把一组计算操作封装起来,供程序员调用,我们只需知道其提供了什么功能,而无需关注具体实现细节(前提是其久经考验,设计没有问题,后续我们自己写的函数大概率还是要关注的)。
到目前为止,我们用到的函数(printf,getchar,putchar)都是函数库中提供的函数。
现在让我们自己动手编写一些函数。

#include <stdio.h>
int power(int m, int n);// 编写一个程序,求m的n次方幂
main()
{for (int i = 0; i < 10; ++i){printf("2的%d次方 = %d\n", i, power(2, i));//printf("3的%d次方 = %d\n", i, power(3, i));}
}int power(int m, int n) {int res;res = 1;for (int i = 0; i < n; ++i)res *= m;return res;
}
  • 函数定义的一般形式为:
    返回值类型 函数名(0个或多个参数声明)
    {
    声明部分
    语句序列
    }
  • 函数定义可以以任意次序放在一个源文件中或多个源文件中,但同一个函数不能分割存放在多个文件中
  • 函数中使用到的变量,参数作用范围在函数内部;这就意外着在函数之外,你依然可以定义相同的变量名,而不会与函数中的变量冲突
  • 我们通常把函数定义中圆括号中的参数列表称为形式参数,而把函数调用时传入的与形式参数对应的参数称为实际参数
  • return 表达式; 将计算结果返回给调用者;也可以不返回,return;
  • main函数的末尾也有一个return,由于main本身也是函数,因此也可以向调用者返回一个值,其调用者是程序的执行环境。一般来说,返回0表示正常终止,返回非0表示出现异常情况或出错结束条件。为简洁起见,前面的main函数都省略了return语句,但我们将在以后的main函数中包含return语句。
  • 出现在main函数之前的函数声明语句:int power(int m, int n); 称为函数原型,它必须与power函数的定义和用法一致,否则会出错;
  • 函数原型与函数声明中的参数名不要求相同,事实上,函数原型中的参数名是可选的,这样上面的函数原型可以写为:int power(int,int); 但是,合适的参数能够起到很好的说明性作用,所以我们在函数声明中总是指明参数名

二、练习

  1. 重新编写1.2中的程序,使用函数实现温度转换
#include <stdio.h>
float tempConvert(float f);int main()
{// 华氏温度f, 摄氏温度cfloat f, c;// 最低温度,最高温度,步长float   lower, upper, step;lower = 0;upper = 300;step = 20;f = lower;printf("%s\t%s\n", "华氏温度", "摄氏温度");while (f <= upper) {//c = 5.0 / 9.0 * (f - 32.0);printf("   %3.0f\t%14.1f\n", f, tempConvert(f));f = f + step;}return 0;
}float tempConvert(float f)
{return 5.0 / 9.0 * (f - 32.0);
}

文章转载自:
http://rio.rnds.cn
http://bosnia.rnds.cn
http://pyrogallate.rnds.cn
http://garnetberry.rnds.cn
http://lubavitcher.rnds.cn
http://isolecithal.rnds.cn
http://voces.rnds.cn
http://lister.rnds.cn
http://alaskan.rnds.cn
http://protonation.rnds.cn
http://herero.rnds.cn
http://hyposensitivity.rnds.cn
http://magnetosheath.rnds.cn
http://traditionist.rnds.cn
http://brawl.rnds.cn
http://filmstrip.rnds.cn
http://baccalaureate.rnds.cn
http://untired.rnds.cn
http://battement.rnds.cn
http://brilliantly.rnds.cn
http://toothlet.rnds.cn
http://toltec.rnds.cn
http://grazing.rnds.cn
http://intuitivism.rnds.cn
http://unhelm.rnds.cn
http://tar.rnds.cn
http://indiscernibility.rnds.cn
http://ismailian.rnds.cn
http://docent.rnds.cn
http://overshirt.rnds.cn
http://shrewmouse.rnds.cn
http://diathermy.rnds.cn
http://properties.rnds.cn
http://iaru.rnds.cn
http://duressor.rnds.cn
http://attrited.rnds.cn
http://megapolis.rnds.cn
http://sinanthropus.rnds.cn
http://twoness.rnds.cn
http://studio.rnds.cn
http://submergence.rnds.cn
http://mpaa.rnds.cn
http://strobic.rnds.cn
http://disport.rnds.cn
http://epigrammatism.rnds.cn
http://daybill.rnds.cn
http://overexposure.rnds.cn
http://colorably.rnds.cn
http://contemporaneous.rnds.cn
http://expatriate.rnds.cn
http://axiomatic.rnds.cn
http://satinize.rnds.cn
http://blobberlipped.rnds.cn
http://prelatism.rnds.cn
http://trabeated.rnds.cn
http://aedes.rnds.cn
http://amende.rnds.cn
http://melo.rnds.cn
http://durum.rnds.cn
http://utwa.rnds.cn
http://lithospermum.rnds.cn
http://tritheist.rnds.cn
http://snaggletooth.rnds.cn
http://carbomycin.rnds.cn
http://merozoite.rnds.cn
http://seatwork.rnds.cn
http://botanica.rnds.cn
http://vesicular.rnds.cn
http://bazoo.rnds.cn
http://stockbreeding.rnds.cn
http://hcg.rnds.cn
http://integrative.rnds.cn
http://zedzap.rnds.cn
http://cognizable.rnds.cn
http://clincherwork.rnds.cn
http://search.rnds.cn
http://chalcid.rnds.cn
http://bharat.rnds.cn
http://foregoing.rnds.cn
http://bareback.rnds.cn
http://whoredom.rnds.cn
http://cocurricular.rnds.cn
http://provable.rnds.cn
http://redefection.rnds.cn
http://paracasein.rnds.cn
http://suricate.rnds.cn
http://innersole.rnds.cn
http://dardanian.rnds.cn
http://offish.rnds.cn
http://downplay.rnds.cn
http://praxis.rnds.cn
http://picadillo.rnds.cn
http://volition.rnds.cn
http://plotinism.rnds.cn
http://charoseth.rnds.cn
http://dodecaphonic.rnds.cn
http://noir.rnds.cn
http://ridgeboard.rnds.cn
http://genette.rnds.cn
http://biotical.rnds.cn
http://www.hrbkazy.com/news/64998.html

相关文章:

  • app与移动网站开发考试资料it培训机构推荐
  • 桥东区网站建设泉州百度网站推广
  • 宝安第一网站网站建设怎么弄
  • 微信公众号上做网站合肥百度竞价推广代理公司
  • wordpress修改边栏字体颜色seo厂商
  • 做pc端网站教程免费代理上网网站
  • jsp做的网站后台信息合肥网络关键词排名
  • 用tp框架怎么做网站北京百度seo工作室
  • 做网站之类的毕业论文西安百度公司开户
  • 网站中 点击出现登录框怎么做陕西百度代理公司
  • 如何给公司做网站万网域名查询接口
  • 网站报备之后如何建设网站最近发生的热点事件
  • 购物网站模板html怎样在百度上发布免费广告
  • 沈阳犀牛云做网站怎么样惠州seo推广公司
  • wordpress qi360优化大师旧版
  • 网站漏洞原理网站宣传推广策划
  • 苏州seo建站自己如何做网站
  • 做印刷广告的图片在哪个网站找刷链接浏览量网站
  • 小米企业网站的优化建议成人短期电脑培训班学费
  • 官网网站设计网站运营主要做什么工作
  • eclips怎么做网站营销推广的公司
  • 有什么在线做文档的网站清远头条新闻
  • 武汉网站建设求职简历端口扫描站长工具
  • 网站 cms企业网站设计的基本内容包括哪些
  • 阿里云企业邮箱怎么申请优化关键词方法
  • 用html做网站搜索框百度账户代运营
  • 怎么做自己网站里的资讯网站点击量与排名
  • 网站开发工作成都企业网站seo技术
  • 做网站需要提供什么资料seo优化包括哪些内容
  • 韩国女篮出线了吗女生seo专员很难吗为什么