1

如何取两个整数中的最大值

 1 year ago
source link: https://blog.51cto.com/u_15806064/5766388
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

如何取两个整数中的最大值

精选 原创

想做老总的大牛 2022-10-18 13:53:44 博主文章分类:初学C语言 ©著作权

文章标签 #include 头文件 取地址 文章分类 C/C++ 编程语言 阅读数194

1.已知两个整数的值:已知两个数分别为25,36,,取下最大值。

#include<stdio.h>

int main()

int num1=25;

int num2=36;

if(num1>num2)

printf("%d\n",num1);

printf("%d\n",num2);

return  0;

2.未知两个数的数值。(调用scanf)

#include<stdio.h>

#include<string.h>//scanf函数的头文件

int main()

int num1=0;

int num2=0;

scanf("%d%d",&num1,&num2);//输入函数,需要取地址

if(num1>num2)

printf("%d\n",num1);

printf("%d\n",num2);

return  0;

3.未知两个整数变量

#include<stdio.h>

#include<string.h>

int Max(int x,inty)

if(x>y)

return x;

return  y;

int main()

int num1=0;

int num2=0;

int max=0;

scanf("%d%d",&num1,&num2);

max=Max(num1,num2);

printf("%d\n",max);

return  0;

  • 收藏
  • 2评论
  • 分享
  • 举报

上一篇:写一个关机程序


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK