עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

משוואה ריבועית ב-C#

Featured Replies

פורסם

double a, b, c, x1, x2, delta = 0;

פורסם

תכניס את הif של הdelta<0 לתוך הelse(בו אתה נותן ערך ל delta).

פורסם
  • מחבר

אתה מתכוון לזה?

using System;

class mishvaa
{
static void Main(string[] args)
{
double a, b, c, x1, x2, delta;
Console.WriteLine("enter the first number");
a = double.Parse(Console.ReadLine());
Console.WriteLine("enter the second number");
b = double.Parse(Console.ReadLine());
Console.WriteLine("enter the third number");
c = double.Parse(Console.ReadLine());
if (a == 0)
{
Console.WriteLine("this is mishvaa");
}
else
{
if (delta < 0)
delta = ((b * b) - (4 * a * c));
}

if (delta < 0)
{
Console.WriteLine("this is baham");
}
else
{
x1 = (-b) + Math.Sqrt(delta) / (2 * a);
x2 = (-b) - Math.Sqrt(delta) / (2 * a);
}

}


}

פורסם

ככה:


delta = ((b * b) - (4 * a * c));

if (delta < 0)
{
Console.WriteLine("this is baham");
}
else
{
x1 = (-b) + Math.Sqrt(delta) / (2 * a);
x2 = (-b) - Math.Sqrt(delta) / (2 * a);
}

פורסם
  • מחבר

תודה רבה! :yelclap:

פורסם

צריך לשים את ה

(-b) + Math.Sqrt(delta)

בסוגריים, אחרת התוצאה תיהיה שגוייה (אלה אם C# לא מפרשת את זה לפי סדר פעולות חשבון?).

חוץ מזה, אתה לא צריך לתת את הפתרון/פתרונות גם כש a=0?

וחוץ מזה מס' 2, כשדלתא קטן מאפס זה לא בח"ם, זה אומר שלמשוואה אין פתרונות.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.