如何取两个整数中的最大值
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.
如何取两个整数中的最大值
精选 原创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评论
- 分享
- 举报
上一篇:写一个关机程序
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK