这段代码不起作用请告诉我原因

这段代码不起作用请告诉我原因

本文介绍了这段代码不起作用请告诉我原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class compare
{
    int num1, num2, num3;

    public void accept()
    {
        Console.WriteLine("Enter First Number");
        num1 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter Second Number");
        num2 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter Third Number");
        num3 = Convert.ToInt32(Console.ReadLine());
    }
    public void display
    {
    if(num1>num2)&&(num1>num3)
    {
        Console.WriteLine("This No is greatest {0}",num1);
    }
        else if(num2>num1)&&(num2>num3)
    {
        Console.WriteLine("This No is greatest {0}",num2);
    }
        else{
        Console.WriteLine("This No is greatest {0}",num3);
    }
    }
     static void Main(string[] args)
        {
            compare  cmp = new compare();
            cmp.accept();
            cmp.display();
        }
}

推荐答案

class compare
{
    int num1, num2, num3;

    public void accept()
    {
        Console.WriteLine("Enter First Number");
        num1 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter Second Number");
        num2 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter Third Number");
        num3 = Convert.ToInt32(Console.ReadLine());
    }
    public void display()
    {
            if((num1>num2)&&(num1>num3))
            {
                Console.WriteLine("This No is greatest {0}",num1);
            }
             else if((num2>num1)&&(num2>num3))
            {
                Console.WriteLine("This No is greatest {0}",num2);
            }
                else
            {
                Console.WriteLine("This No is greatest {0}",num3);
            }
            
    }
    static void Main(string[] args)
    {
        compare cmp = new compare();
        cmp.accept();
        cmp.display();
        Console.Read();
    }

}


这篇关于这段代码不起作用请告诉我原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 06:01