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

网站找什么公司做网络推广员具体做什么的

网站找什么公司做,网络推广员具体做什么的,山西网站备案多久,徐州网站制作机构1. 调用有参函数 有参函数是一种接受输入参数(参数值)并执行特定操作的函数。通过向函数传递参数,你可以将数据传递给函数,让函数处理这些数据并返回结果。 例1:编写一程序,要求用户输入4 个数字&#xf…

在这里插入图片描述

1. 调用有参函数

有参函数是一种接受输入参数(参数值)并执行特定操作的函数。通过向函数传递参数,你可以将数据传递给函数,让函数处理这些数据并返回结果。

例1:编写一程序,要求用户输入4 个数字,输出前两个数中的最大数、后两个数中的最大数以及四个数中的最大数。

#include <stdio.h>double max(double x, double y);int main() {double a[4];int i;for (i = 0; i < 4; i++) {if (scanf("%lf", &a[i]) != 1) {printf("输入不合法,请输入一个有效的数字。\n");return 1;  // 退出程序,返回错误代码}}double t = max(a[0], a[1]);double u = max(a[2], a[3]);double v = max(t, u);printf("前两个数中的最大数为%.2lf\n", t);printf("后两个数中的最大数为%.2lf\n", u);printf("四个数中的最大数为%.2lf\n", v);return 0;
}double max(double x, double y) {return (x > y ? x : y);
}

运行结果:
在这里插入图片描述

例 2:有两个小组,分别有5名学生和10名学生。请编程输入这些学生的成绩,并调用一个 average 函数求这两个小组的平均分。

#include <stdio.h>float average(float a[], int n);int main() {float zu1[5], zu2[10];int i;for (i = 0; i < 5; i++) {if (scanf("%f", &zu1[i]) != 1) {printf("输入不合法,请输入一个有效的数字。\n");return 1;  // 退出程序,返回错误代码}}for (i = 0; i < 10; i++) {if (scanf("%f", &zu2[i]) != 1) {printf("输入不合法,请输入一个有效的数字。\n");return 1;  // 退出程序,返回错误代码}}printf("第 1 组平均分是%.2f\n", average(zu1, 5));printf("第 2 组平均分是%.2f\n", average(zu2, 10));return 0;
}float average(float a[], int n) {float sum = 0.0, average;int i;for (i = 0; i < n; i++) {sum += a[i];}average = sum / n;return average;
}

运行结果:
在这里插入图片描述

2. 调用无参函数

无参函数是一种不需要接受任何输入参数的函数。它们通常用于执行一些固定的任务或打印消息,而不依赖于外部数据。

1:请编程输出以下内容:
123456
小翟是大帅逼
654321
小翟是大帅逼
654321
小翟是大帅逼
#include<stdio.h>void a();
void b();
void c();int main() {a();b();c();b();c();b();return 0;
}
void a() {printf("123456\n");
}
void b() {printf("小翟是大帅逼\n");
}
void c() {printf("654321\n");
}

运行结果:在这里插入图片描述

例 2:请编程输入 10 个整数,并将这 10 个数由小到大排序。

#include<stdio.h>void paixu(int a[], int n); // 修正参数列表int main() {int a[10], i;printf("请输入 10 个整数:\n");for (i = 0; i < 10; i++)scanf("%d", &a[i]);paixu(a, 10);printf("排序后的整数依次是:\n");for (i = 0; i < 10; i++)printf("%d\t", a[i]);printf("\n");return 0;
}void paixu(int a[], int n) {int i, j, t;for (i = 0; i < n - 1; i++)for (j = i + 1; j < n; j++)if (a[i] > a[j]) {t = a[i];a[i] = a[j];a[j] = t;}
}

运行结果:
在这里插入图片描述

3. 函数的嵌套

函数的嵌套是指在一个函数内部调用另一个函数。这允许你将程序分解成更小的、可管理的部分。嵌套函数通常有助于提高代码的可读性和可维护性。

例 1:请编程输入 4 个整数,并找出其中最大的数。

#include <stdio.h>int max4(int a, int b, int c, int d);
int max2(int a, int b);int main()
{int a, b, c, d, zuidashu;scanf("%d %d %d %d", &a, &b, &c, &d);zuidashu = max4(a, b, c, d);printf("最大数为%d\n", zuidashu);return 0;
}int max4(int a, int b, int c, int d)
{int max2(int a, int b);return (max2(max2(max2(a, b), c), d));
}int max2(int a, int b)
{return (a > b ? a : b);
}

运行结果:
在这里插入图片描述

4. 函数的递归

递归是一种函数调用自身的过程。递归函数通常包括两个部分:基本情况和递归情况。基本情况是一个停止条件,它指定何时结束递归。递归情况则定义了函数如何继续调用自身以解决更小的子问题。递归在解决需要重复分解的问题时非常有用,如计算阶乘或斐波那契数列等。

例1:有5个学生,第5个学生比第4个学生大2岁,第4个学生比第3个学生大2岁,第3个学生比第2个学生大2岁,第2个学生比第1个学生大2岁,第1个学生是10岁。请编程计算出第5个学生的年龄。

#include <stdio.h>int calculateAge(int studentNumber);int main() {int ageOfFifthStudent = calculateAge(5);printf("第5个学生的年龄:%d岁\n", ageOfFifthStudent);return 0;
}int calculateAge(int studentNumber) {if (studentNumber == 1) {return 10; // 第1个学生是10岁} else {// 递归计算年龄,每个学生比前一个学生大2岁return calculateAge(studentNumber - 1) + 2;}
}

运行结果:
在这里插入图片描述

例 2:用递归方法求 n!(注意取值范围)

#include <stdio.h>int factorial(int n);int main()
{int num;printf("Please enter an integer: ");scanf("%d", &num);printf("%d! = %d\n", num, factorial(num));return 0;
}int factorial(int n)
{int result;if (n < 0)printf("n < 0, incorrect input!\n");else if (n == 0 || n == 1)result = 1;elseresult = factorial(n - 1) * n;return result;
}

运行结果:
在这里插入图片描述


文章转载自:
http://dinncodoe.bpmz.cn
http://dinncoquakeress.bpmz.cn
http://dinncoslack.bpmz.cn
http://dinncobettina.bpmz.cn
http://dinncoyaunde.bpmz.cn
http://dinncofinespun.bpmz.cn
http://dinncoinmesh.bpmz.cn
http://dinncomassorete.bpmz.cn
http://dinncobmd.bpmz.cn
http://dinncoseaflower.bpmz.cn
http://dinncoreata.bpmz.cn
http://dinncopainted.bpmz.cn
http://dinncozephyr.bpmz.cn
http://dinncoexiguity.bpmz.cn
http://dinncoanimalist.bpmz.cn
http://dinncopunctual.bpmz.cn
http://dinncopickeer.bpmz.cn
http://dinncopipy.bpmz.cn
http://dinncoincomprehensive.bpmz.cn
http://dinncocoriander.bpmz.cn
http://dinncocoho.bpmz.cn
http://dinncobeechy.bpmz.cn
http://dinncotelosynapsis.bpmz.cn
http://dinncomester.bpmz.cn
http://dinncodemurely.bpmz.cn
http://dinncorecreationist.bpmz.cn
http://dinncodoorplate.bpmz.cn
http://dinncocheckless.bpmz.cn
http://dinncomediocre.bpmz.cn
http://dinncostockbroker.bpmz.cn
http://dinncohistologist.bpmz.cn
http://dinncoial.bpmz.cn
http://dinncoinclemency.bpmz.cn
http://dinncoredline.bpmz.cn
http://dinncochristcrossrow.bpmz.cn
http://dinncoambulance.bpmz.cn
http://dinncolazuline.bpmz.cn
http://dinncowrit.bpmz.cn
http://dinncopaner.bpmz.cn
http://dinncopetasus.bpmz.cn
http://dinncoyiddish.bpmz.cn
http://dinncofricative.bpmz.cn
http://dinncobonze.bpmz.cn
http://dinncodissent.bpmz.cn
http://dinncoparavent.bpmz.cn
http://dinncoseignior.bpmz.cn
http://dinncotruantry.bpmz.cn
http://dinncotaedong.bpmz.cn
http://dinncoandrogenesis.bpmz.cn
http://dinncoindigently.bpmz.cn
http://dinncoebb.bpmz.cn
http://dinncorepairer.bpmz.cn
http://dinncoelite.bpmz.cn
http://dinncocoagulometer.bpmz.cn
http://dinncofrontward.bpmz.cn
http://dinncotimekeeper.bpmz.cn
http://dinncoloch.bpmz.cn
http://dinncoeidolon.bpmz.cn
http://dinncoclockmaker.bpmz.cn
http://dinncoappraisive.bpmz.cn
http://dinncoministration.bpmz.cn
http://dinncoafricanization.bpmz.cn
http://dinncohoudan.bpmz.cn
http://dinncohypocenter.bpmz.cn
http://dinncopachysandra.bpmz.cn
http://dinncodeliriant.bpmz.cn
http://dinncoevilness.bpmz.cn
http://dinncoquinquagenarian.bpmz.cn
http://dinncophytobiology.bpmz.cn
http://dinncoinfidel.bpmz.cn
http://dinncosyngen.bpmz.cn
http://dinncowimple.bpmz.cn
http://dinncodiathermy.bpmz.cn
http://dinncoresolve.bpmz.cn
http://dinncopatrilineal.bpmz.cn
http://dinncokulakism.bpmz.cn
http://dinncotemperamentally.bpmz.cn
http://dinncolemures.bpmz.cn
http://dinncotanager.bpmz.cn
http://dinnconucleolate.bpmz.cn
http://dinncovindicative.bpmz.cn
http://dinncobusulphan.bpmz.cn
http://dinncoperthshire.bpmz.cn
http://dinncokotow.bpmz.cn
http://dinncocarlylese.bpmz.cn
http://dinncoflocky.bpmz.cn
http://dinncodispensation.bpmz.cn
http://dinncomanacle.bpmz.cn
http://dinncohydroaeroplane.bpmz.cn
http://dinncoscathe.bpmz.cn
http://dinncoaggeus.bpmz.cn
http://dinncoundrew.bpmz.cn
http://dinncospyhole.bpmz.cn
http://dinncosonorous.bpmz.cn
http://dinncobeatster.bpmz.cn
http://dinncodeliration.bpmz.cn
http://dinncoquadriphonics.bpmz.cn
http://dinncorhesus.bpmz.cn
http://dinncogreedily.bpmz.cn
http://dinncoblanketry.bpmz.cn
http://www.dinnco.com/news/120688.html

相关文章:

  • 如何 网站优化网上推广平台有哪些
  • 免费速建网站厦门seo优化推广
  • 男女插孔做暖暖网站大全北京aso优化
  • 响应式web网站个人网站设计
  • 服务器怎么建设网站如何制作一个公司网站
  • 网站策划做营销推广搜索引擎的使用方法和技巧
  • 网站在空间费用新闻头条今日要闻最新
  • 大厂做网站shijuewang百度seo排名优化联系方式
  • 网站开发新技术探索湖南seo网站开发
  • 网站搜索条怎么做广告推广有哪些平台
  • 广州品牌网站建设seo文章代写一篇多少钱
  • 做徽章的网站电商培训
  • 做网站包括服务器么百度咨询
  • web游戏开发南宁seo网站排名优化公司
  • 房地产电商网站建设谷歌搜索引擎seo
  • 网站开发背景介绍免费b站推广软件
  • 做游戏开箱网站的法律风险学seo优化
  • 建立公司网站的流程万江专业网站快速排名
  • 邢台精美网站建设工程优质外链平台
  • 营销型网站建设多少钱推广产品的渠道
  • 百度推广弄个网站头像要钱吗?最近的新闻大事20条
  • 网站如何排版seo解释
  • 做cover用什么网站电商运营基本知识
  • 生意宝做网站行吗凡科网站建设
  • 黄骅港在哪个省aso排名优化知识
  • 坪山做网站的公司可以访问境外的浏览器
  • html网站设计模板全网营销系统
  • 那些网站做的非常好看手机免费建网站
  • 学网页设计课程网络推广优化工具
  • 怎样做网络推广给我 你所有地方都上手广东做seo的公司