PHP 再帰問題
- PHP コード
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> function test($a) { echo ' '.$a.' '; if($a >0) { test($a-1); }else { echo ''; } echo '<b>'.$a.'</b>'; } test(3)
3 2 1 0 0 1 2 3
英雄の皆様、お願いします操作手順を説明するか、参考資料をクリックして勉強してください。私は初心者です。ご了承ください
-----解決策---------------------------- --
お兄さん、関数を呼び出すときは、再帰呼び出しテスト($a-1)が完了したら、新しいスタックを開く必要があります。出力、わかりますか?
そしてもちろん次は わかりますか?
最終的に、開いたスタックをリサイクルするときは、この echo ''.$a.''; ~~~
何か理解できない場合は、指摘して頑張ってください~~
------解決策---------
すべてのレイヤーは同じです:
1、print $a
2、次のレベルの再帰を入力するか、print
3、print $a
その後:
print 3 . 2 を印刷、1 を印刷、0 を印刷、、0 を印刷、1、2 を印刷、3 を印刷。
赤はステップ 1、青はステップ 2 です。
------解決策---------
test(3) 関数テストを実行します:
1. echo $a = 3 を実行し、if 判定 3>0 を入力して test(2) を実行します。ここでは関数 test(3) がまだ実行されていません。まず test(2) を実行します ------- *1;
2. test(2) echo $a = 2 そして 2>0 と判断して test(1) を実行します。まだ実行されていません。まずはtest(1)を実行 ------------*2;
3.test(1) echo $a = 1; 次に1>0と判定してここでtest(0)を実行します。 (1)はまだ実行されていません。まずtest(0) -----------*3;
4. test(0) echo $a = 0; 次に0>0を判定してecho を実行します。 echo 0;
5. 4の実行後、*3に戻ります。判定が完了したら、echo $a = 1;
6. 5の実行後、*に戻ります。 2 echo $a = 2;
7. 6 実行後は*1に戻ります echo $a = 3;
これはレイヤーごとに進み、レイヤーごとに出力されます。

LeicareleasedtheLeicaLuxcameraappfortheAppleiPhoneafewdaysago.However,theappwasnotdevelopedbyLeica,butbyFjorden.ThecompanyhasbeenknownprimarilyforitscameragripsfortheiPhoneandwasacquiredbyLeicainDecember2023.Fo

SincethedemiseofLogitech'spopularHarmonyremotecontrols,themarketforhigh-qualityuniversalremotecontrolshasbeenfragmentedatbest.UnfoldedCircleaimstoavoidthefateoftheHarmonyUltimatebyeliminatinganyserverobligationsorsubs

Anintriguingthird-partycasefortheGalaxyS24Ultra(curr.$1,099.99onAmazon)hasappearedonmarketplaceslikeAliExpress.Astheimagesthroughoutthisarticleshow,thecasehasasimplesiliconeconstruction.However,italsocontainsanEInkd

In2012,theeminentautomotivejournalistJeremyClarksonstatedthattheLamborghiniAventador,whichhewasreviewingatthetime,wouldbeamongthelastcarstofeatureanaturallyaspiratedV12.Morethanadecadelater,V12-poweredsupercarsareal

WhiletheLightPhone2from2018wasstillequippedwithaneconomicale-inkdisplay,theLightPhone3usesanOLEDdisplaythatcanonlydisplaygrayscale.Thereasonfortheswitchtothe3.92-inchOLEDpanelwithitsresolutionof1,240x1,080isth

Audio-TechnicahasunveiledtheATH-S300BTwirelessheadphoneswithhear-throughnoise-cancellation,multipointpairing,and90hoursofbatterylife.Thenoise-cancellingfeaturehasthreemodes:off,on,andhear-through,whereambientsoundscanbehea

Backin2022,whenPCIe7.0wasstartingtotakeshapeasafuturestandard,PCIe5.0wasjusthittingtheservermarketsandtheprospectofseeingPCIe6.0devicesavailableanytimesoon,letalonePCIe7.0ones,wasquitefar-fetched.CurrentlyPCIe5

TheJabraEliteserieshascometoanend,withGNCEOPeterKarlstromerannouncingthediscontinuationofthewirelessearbudswithinthelineupinapressrelease.Petersaysthatthechangingmarketdynamicsandhowchallengingithasbecometogetas


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

SublimeText3 中国語版
中国語版、とても使いやすい

DVWA
Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

VSCode Windows 64 ビットのダウンロード
Microsoft によって発売された無料で強力な IDE エディター

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

ホットトピック



