לשאלה המלאה לחצו כאןמחיר כרטיס לסרט שובר קופות הוא...
לשאלה המלאה לחצו כאן
מחיר כרטיס לסרט שובר קופות הוא 45 שקלים
פתרון סעיף א בשפת C#
public static int prices()
{
int pricePerOne = 45;
int max = 0; // שומר את המקסימום
int position = 0; // מחזיק במיקום התור של המקסימום
for(int i=1; i<=10; i++)
{
Console.WriteLine("How many tickets do you want?);
int tickets = int.Parse(Console.ReadLine());
int price = tickets*pricePerOne ;
if( price >max )
{
max = price;
position = i;
}
Console.WriteLine("The final price is: "+price);
}
return position;
}
פתרון סעיף ב' בשפת C#
int counter=0;
for(int i=0; i<7; i++)
{
for(int j=0; j<10; j++)
{
if( prices()==1)
counter++;
}
Console.WriteLine("The answer is:"+counter);
}