אוקי עם התוכנית הזאת הצלחתי להגיע שזה עושה את ההפרש אבל אם אני מכניס מספרים כמו 31 ו60 זה מחשב את ההפרש במקום לכתוב . error
קוד:
{
int x, y;
x = int.Parse(Console.ReadLine());
y = int.Parse(Console.ReadLine());
if (x>y)
switch (x)
{
case 0 :
Console.WriteLine(y-x); break;
case 15:
Console.WriteLine(y-x); break;
case 30:
Console.WriteLine(y-x); break;
case 40:
Console.WriteLine(y-x); break;
case 60:
Console.WriteLine(x-y); break;
default:
Console.WriteLine("error"); break;
}
else
switch (y)
{
case 0:
Console.WriteLine(x-y); break;
case 15:
Console.WriteLine(x-y); break;
case 30:
Console.WriteLine(x-y); break;
case 40:
Console.WriteLine(x-y); break;
case 60:
Console.WriteLine(y-x); break;
default:
Console.WriteLine("error"); break;
}
}
}
}