View Single Post
ישן 14-11-07, 21:24   # 2
JSC
חבר חדש
 
מיני פרופיל
תאריך הצטרפות: Feb 2006
הודעות: 29

JSC לא מחובר  

גם בתרגיל 1 צריך if כן?

נראה לי שכן, כי Math.Max מקבל רק 2 ערכים ולא יותר [כמו בשאלה הזאת שצריך 4]
אז הנה עם if:

HTML קוד:
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int h1,h2,h3,h4;
            Console.WriteLine("תן הצעה אחי");
            h1 = int.Parse(Console.ReadLine());
            Console.WriteLine("תן הצעה אחי");
            h2 = int.Parse(Console.ReadLine());
            Console.WriteLine("תן הצעה אחי");
            h3 = int.Parse(Console.ReadLine()); 
            Console.WriteLine("תן הצעה אחי");
            h4 = int.Parse(Console.ReadLine());
            if ((h1 > h2) && (h1 > h3) && (h1 > h4))
            {
                Console.WriteLine("the wineer is: {0}", h1);
            }
            else
            {
                if ((h2 > h1) && (h2 > h3) && (h2 > h4))
                {
                    Console.WriteLine("the wineer is: {0}", h2);
                }
                else if ((h3 > h1) && (h3 > h2) && (h3 > h4))
                {
                    Console.WriteLine("the wineer is: {0}", h3);
                }
                else
                {
                    Console.WriteLine("the wineer is: {0}", h4);
                }
            }
                    
        }
    }
}
תרגיל 2 אני תכף אשלח, תגיד לי אם זה בסדר קודם כל.
__________________
ניסו ...:P

Last edited by JSC; 14-11-07 at 21:31..
  Reply With Quote