#include <stdio.h>
int max_num(int a[],int curr,int next,int next_next)
{
int max;
if(next == 3)//結束的條件
max = a[curr]>a[next]?a[curr]:a[next];
else
{
if(a[curr]>a[next])
max_num(a,curr,next_next,next_next+1);//遞歸
else max_num(a,next,next_next,next_next+1);
}
}
void main()
{
int j;
int num[4];
for(j=0;j<4;j++)
scanf("%d",&num[j]);
printf("\n%d",max_num(num,0,1,2));
}
輸入4個整數,用遞歸方法找出最大值
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
N網下載mod方法: 20240614親測好使
https://www.bilibili.com/video/BV1k8411575T/?vd_source=d68ed178f151e80fea1e02efd205802c
張博的博客
2024-06-15 14:23:44
Libgdx遊戲開發(3)——通過柏林噪音算法地圖隨機地形
Stars-one
2024-06-15 14:23:14
langchain Chatchat 學習實踐(四)——實現對Text2Sql的支持
鄭某
2024-06-15 14:19:14
python cuda12 安裝
菊花茶
2024-06-15 14:15:03
解決#error -- unsupported GNU version! gcc versions later than 11 are not supported!
Dsp Tian
2024-06-15 14:14:43
Codeforces Global Round 26 D ''a'' String Problem(思維)
SnowLove
2024-06-15 14:14:03
前端使用 Konva 實現可視化設計器(15)- 自定義連接點、連接優化
xachary
2024-06-15 14:11:43
爲centos7系統添加新用戶並設置祕鑰登陸
憤怒的碼農
2024-06-15 14:09:23
Odoo jsonb查詢
若-飛
2024-06-15 14:07:53
在 Solidity 中將地址類型轉換爲 IERC20 接口類型
若-飛
2024-06-15 14:07:53
solidity calldata學習
若-飛
2024-06-15 14:07:53
理解 Solidity 中的修飾器(Modifiers)
若-飛
2024-06-15 14:07:53
探索 Solidity 中的各種修飾符
若-飛
2024-06-15 14:07:53