浙大版《C语言程序设计(第3版)》题目集

练习5-2 找两个数中最大者

本题要求对两个整数a和b,输出其中较大的数。

函数接口定义:

int max( int a, int b );

其中ab是用户传入的参数,函数返回的是两者中较大的数。

裁判测试程序样例:

#include <stdio.h>

int max( int a, int b );

int main() {

int a, b;

scanf("%d %d", &a, &b);

printf("max = %d\n", max(a, b));

return 0; }

/* 你的代码将被嵌在这里 */

输入样例:

复制代码
-5 8

输出样例:

复制代码
max = 8

#include <stdio.h>

#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int max(int a,int b);

int main(int argc, char *argv[]) {

int a,b;

scanf("%d %d",&a,&b);

printf("max = %d\n",max(a,b));

return 0;

}

int max(int a,int b){

if(a>b){

return a;

}

return b;

}

相关推荐
水云桐程序员4 小时前
C++可以写手机应用吗
开发语言·c++·智能手机
平凡但不平庸的码农5 小时前
Go Slice 详解
算法·golang
Jasmine_llq8 小时前
《B3867 [GESP202309 三级] 小杨的储蓄》
算法·循环遍历·数组累加(模拟)·索引定位·顺序输出
啦啦啦_99998 小时前
案例之 逻辑回归_电信用户流失预测
算法·机器学习·逻辑回归
风筝在晴天搁浅8 小时前
快手/字节 CodeTop LeetCode 415.字符串相加
算法·leetcode
小黄人软件8 小时前
C++读写编辑CSV文件示例源码 用于数据导入导出,比Excel好使
开发语言·c++·excel
郭涤生8 小时前
C++各个版本的性能和安全性总结
开发语言·c++
DragonnAi9 小时前
猫咪如厕检测与分类识别系统系列【十四】 项目结构重新整理-即将开源完整算法
算法·开源
机器视觉_Explorer9 小时前
【halcon】编程技巧:鼠标擦除
图像处理·人工智能·深度学习·算法·视觉检测
wljy110 小时前
二、静态库的制作和使用
linux·c语言·开发语言·c++