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

网站开发的条件重庆哪里有做淘宝网站推广的

网站开发的条件,重庆哪里有做淘宝网站推广的,大连网站推广招聘,浙江虎霸建设机械有限公司网站作用#xff1a;将一段经常使用的代码封装起来#xff0c;减少重复代码 一个较大的程序#xff0c;一般分为若干个程序块#xff0c;每个模块实现特定的功能 一、函数的定义及调用 函数的定义一般主要有5个步骤#xff1a; 返回值类型函数名参数表列函数体语句return表…作用将一段经常使用的代码封装起来减少重复代码 一个较大的程序一般分为若干个程序块每个模块实现特定的功能 一、函数的定义及调用 函数的定义一般主要有5个步骤 返回值类型函数名参数表列函数体语句return表达式 语法 返回值类型 函数名(参数列表) {函数体语句;return 表达式; } 1、实现一个加法的函数 功能传入两个整型数据计算数据相加的结果并且返回 返回值类型函数名参数列表函数体语句return表达式 #includeiostream #includestring.h using namespace std;int add(int num1, int num2) //形参num1,num2 {int sum num1 num2;return sum; }int main() {//函数的定义//语法//返回值类型 函数名 参数列表 {函数体语句 return 表达式}//加法函数实现两个整型相加并且将相加的结果进行返回int a 10; //实参int b 20; //实参int sum add(a, b); //调用函数cout sum endl;sumadd(1, 2); //调用函数cout sum endl;system(pause);return 0; } 运行结果 3 30 注当调用函数时实参的值回传递给形参 二、函数的值传递 #includeiostream #includestring.h using namespace std;void swap(int num1, int num2) {cout 交换前 endl;cout num1 num1 endl;cout num2 num2 endl;int temp num1;num1 num2;num2 temp;cout 交换后 endl;cout num1 num1 endl;cout num2 num2 endl;//return;返回值不需要的时候可以不写returnreturn; }int main() {//值传递//定义函数实现两个数字进行交换函数//如果一个函数不需要返回值声明时可以写voidint a 10; //实参int b 20; //实参cout a a endl;cout b b endl;//当我们做值传递的时候函数的形参发生改变并不会影响实参swap(a, b); //调用函数system(pause);return 0; } 运行结果 a 10 b 20 交换前 num1 10 num2 20 交换后 num1 20 num2 10 三、函数的常见样式 常见的函数样式有4种 无参无返有参无返无参有返有参有返 #includeiostream #includestring.h using namespace std; //函数常见样式 //1、无参无返 void test01() {cout this is test01 endl; }//2、有参无返 void test02(int a) //参数 {cout this is test02 a a endl; } //3、无参有返 int test03() //参数 {cout this is test03 endl;return 1000; }//4、有参有返 int test04(int a) {cout this is test04 a a endl;return a; }int main() {//1、无参无返函数调用test01();//2、有参无返函数调用test02(100);//3、无参有返函数调用int num1 test03();cout num1 num1 endl;{cout this is test03 endl;}//4、有参有返函数调用int num2 test04(10000);cout num2 num2 endl;system(pause);return 0; } 运行结果 this is test01 this is test02 a 100 this is test03 num1 1000 this is test03 this is test04 a 10000 num2 10000 四、函数的声明 作用告诉编译器去函数名称以及如何调用函数。函数的实际主体可以单独定义 函数的声明可以多次但是函数的定义只能有一次 #includeiostream #includestring.h using namespace std; //函数的声明 //比较函数实现两个整型数字进行比较返回较大的值 int max(int a, int b); //函数的声明int main() {int a 10;int b 20;cout max(a, b) endl;system(pause);return 0; }int max(int a, int b) {return a b ? a : b; //三目运算符 } 运行结果 20 五、函数的文件编写 作用让代码结构更加清晰 函数分文件编写一般有4个步骤 创建后缀为.h的头文件创建后缀名为.cpp的源文件在头文件中写函数的声明在源文件中写函数的定义 1、交换两个数字 创建swap.h头文件 #includeiostream #includestring.h using namespace std; void swap(int a, int b); //函数的声明 创建swap.cpp源文件此文件中写函数的定义 //函数的定义 #include swap.h //与头文件进行关联 void swap(int a, int b) {int temp a;a b;b temp;cout a a endl;cout b b endl; } 主函数文件test.cpp //函数的分文件编写 //实现两个数字进行交换的函数不需要返回值//1、创建.h后缀名的头文件 //2、创建.cpp后缀名的源文件 //3、在头文件中写函数的声明 //4、在源文件中先函数的定义#include swap.h //使用函数需引用头文件 int main() {int a 10;int b 20;swap(a, b);system(pause);return 0; }
http://www.pierceye.com/news/572538/

相关文章:

  • 建一个电影网站多大 数据库半厘米wordpress
  • 住房和建设厅网站首页网站源码怎么写
  • 宁波新亚建设公司网站简单网站建设
  • 做网站没赚到钱网站后台地址忘记了
  • 备案网站公共查询安阳县
  • wordpress 超级管理员seo优化网络公司
  • 商务推广网站宝塔做网站
  • 我想建一个网站怎么建python做的大型网站
  • 为网站设计手机版wordpress怎样比较安全
  • 网站优化方式重庆建设网站哪家专业
  • php做网站基本流程旅游网站论文
  • 网站前期准备网页制作需要学多久
  • 广园路建设公司网站建app网站要多少钱
  • 网站域名是什么东西wordpress农历插件
  • 专业网站建设公司首选公司wordpress fruitful
  • 微博wap版登录入口seo 网站标题长度
  • 网站面包屑导航设计即位置导航局域网安装wordpress
  • 泰安网站建设xtempire国家开放大学网站界面设计
  • 绘制网站结构图建站公司售后服务
  • 漂亮的博客网站模板装修公司网站开发
  • 厦门网站注册与网页设计公司wordpress找不到php的拓展
  • 常熟网站建设icp备案自己怎样创建网站
  • 移动互联网站建设seo流量排名门户
  • 做腰椎核磁证网站是 收 七设计网络品牌营销方案思路
  • 外贸网站建站系统基于php网站开发
  • 可以做代销的网站都有哪些神马网站快速排名案例
  • 个人能申请网站吗百度站长提交网址
  • 给素材网站做签约设计不想做了网络规划设计师教程第2版pdf
  • 新做的网站怎样推广html代码加密
  • 织梦淘宝客网站嘉兴网站开发公司