תודה!!מתוך Quara
It’s not necessary, but it is often helpful. The usual reason I use a wrapper function is to reduce the number of parameters in the recursive call. This reduces the stack usage, as all parameters are pushed on the stack for each call, and if there are many parameters and many layers of recursion, there could be a stack overflow. Any parameters that do no change for the recursive call can be left in an enclosing lexical scope or passed altogether as a reference to a structure.
הרעיון הוא לחסוך בהעמסת מידע מיותרת על זיכרון המחשב.
ואאהו תודה!!C#:void printNumbers1(int x){ void printNumbers2(int t){ if (t <= x){ cout << t << t; printNumbers2(++t); cout << t << t; } printNumbers2(1); } }
איך מתרגמים את זה לסי שארפ??C#:void printNumbers1(int x){ void printNumbers2(int t){ if (t <= x){ cout << t << t; printNumbers2(++t); cout << t << t; } } printNumbers2(1); }
איך מתרגמים את זה לסי שארפ??
namespace ConsoleApp1
{
class Program
{
public static void printNumbers(int x)
{
void print(int i)
{
Console.Write("{0}{1}", i, i);
if (i >= x)
return;
print(i + 1);
Console.Write("{0}{1}", i, i);
}
print(1);
}
static void Main(string[] args)
{
printNumbers(4);
Console.Read();
}
}
}
אין מילים!!!C#:namespace ConsoleApp1 { class Program { public static void printNumbers(int x) { void print(int i) { Console.Write("{0}{1}", i, i); if (i >= x) return; print(i + 1); Console.Write("{0}{1}", i, i); } print(1); } static void Main(string[] args) { printNumbers(4); Console.Read(); } } }
לוח לימודים
מסלולי לימוד שאפשר לההצטרף
אליהם ממש עכשיו:
4.06
כ"ז אייר
סילבוס חדש ל-2024!
קורס פיתוח ובניית אתרים
קריירה מתקדמת, ביקוש עצום, וממוצע משכורות גבוה במיוחד!
מלגות גבוהות ומשתלמות!
2.06
כ"ה אייר
פתיחת מסלול
קורס עריכת וידאו
מלגות והנחות משמעותיות!
4.06
כ"ז אייר
#רקבפרוג
הרצאה מרתקת:
הכירו את טווינמושן
עם גל אקסלרוד
עולם מטורף משל הדמיות! ממשק חדשני שמאפשר לבצע הדמיה כמעט כמו משחק מחשב
לתלמידים ובוגרים בלבד!
27.06
כ"א סיוון
פתיחת מסלול
עיצוב ואדריכלות פנים
מלגות גבוהות!
27.06
כ"א סיוון
השקה חגיגית!
עיצוב גרפי ודיגיטל - בסילבוס חדש ומטורף!
מלגות גבוהות!
תהילים פרק קנ
א הַלְלוּיָהּ הַלְלוּ אֵל בְּקָדְשׁוֹ הַלְלוּהוּ בִּרְקִיעַ עֻזּוֹ:ב הַלְלוּהוּ בִגְבוּרֹתָיו הַלְלוּהוּ כְּרֹב גֻּדְלוֹ:ג הַלְלוּהוּ בְּתֵקַע שׁוֹפָר הַלְלוּהוּ בְּנֵבֶל וְכִנּוֹר:ד הַלְלוּהוּ בְתֹף וּמָחוֹל הַלְלוּהוּ בְּמִנִּים וְעוּגָב:ה הַלְלוּהוּ בְצִלְצְלֵי שָׁמַע הַלְלוּהוּ בְּצִלְצְלֵי תְרוּעָה:ו כֹּל הַנְּשָׁמָה תְּהַלֵּל יָהּ הַלְלוּיָהּ: