Code C#: Ví dụ cấu trúc IF...ELSE

Người đăng: share-nhungdieuhay on Thứ Hai, 11 tháng 3, 2013


//Viết chương trình cho phép nhập 3 số nguyên từ bàn phím. In ra số lớn nhất.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Max_3_so{
class Program{
static void Main(string[] args){

int a, b, c;

Console.Write("Nhap gia tri a:");
a = int.Parse(Console.ReadLine());
Console.Write("Nhap gia tri b:");
b = int.Parse(Console.ReadLine());
Console.Write("Nhap gia tri c:");
c= int.Parse(Console.ReadLine());

if (a > b)
   if (a > c) Console.Write("Gia tri lon nhat la:{0}.",a);
   else Console.Write("Gia tri lon nhat la:{0}.", z);
else if (b > c) Console.Write("Gia tri lon nhat la:{0}.",b);
   else Console.Write("Gia tri lon nhat la:{0}.",c);

Console.ReadLine(); 
    }
  }
}


{ 0 nhận xét... read them below or add one }

Đăng nhận xét