|
|
# 2 |
|
חבר חדש
|
גם בתרגיל 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);
}
}
}
}
}
__________________
ניסו ...:P Last edited by JSC; 14-11-07 at 21:31.. |
|
| חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים) | |
| כלים לאשכול | |
| תצורת הצגה | |
|
|