9 תשובות
מתי את מפסיקה לקלוט מספרים?
שואל השאלה:
אין לי מושג. שאלה לא מובנת. די קיוויתי שיבינו פה
אין לי מושג. שאלה לא מובנת. די קיוויתי שיבינו פה
אנונימית
זה בדיוק מה שכתבו לך?
שואל השאלה:
מילה למילה
מילה למילה
אנונימית
אכפת לך מביצועים?
שואל השאלה:
מניחה שלא
מניחה שלא
אנונימית
אז תיצרי פונקציית עזר:
int f(int x)
{
if (x==1)
return 1;
return x* f(x-1);
}
int f(int x)
{
if (x==1)
return 1;
return x* f(x-1);
}
ואז הלולאה תהיה:
int input;
לא זוכר מה הסינטקס לקלט, משהו עם consol. משהו.
(while(input > 0
{
תדפיסי את f(input)
תקלטי מספר חדש.
}
int input;
לא זוכר מה הסינטקס לקלט, משהו עם consol. משהו.
(while(input > 0
{
תדפיסי את f(input)
תקלטי מספר חדש.
}
זה תכנית שקולטת מספר אחד ומדפיסה את העצרת שלו כמובן שזה סי שארפ אז אין לי כל כך ידע בזה אם היה לי ידע הייתי מצליח לענות על השאלה בשלמותה
using system;
public class factorialexample
{
public static void main(string[] args)
{
int i,fact=1,number;
console.write("enter any number: ");
number= int.parse(console.readline());
for(i=1;i<=number;i++){
fact=fact*i;
}
console.write("factorial of " +number+" is: "+fact);
}
}
using system;
public class factorialexample
{
public static void main(string[] args)
{
int i,fact=1,number;
console.write("enter any number: ");
number= int.parse(console.readline());
for(i=1;i<=number;i++){
fact=fact*i;
}
console.write("factorial of " +number+" is: "+fact);
}
}
באותו הנושא: