Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- // Напишете метод, който при подадено име отпечатва на конзолата "Hello, <name>!" (например "Hello, Peter!")
- // Напишете програма, която тества дали този метод работи правилно.
- // Използвайте метод с параметър string
- static void Main(string[] args)
- {
- Console.Write("Please enter your name:");
- SayHello(Console.ReadLine());
- }
- static void SayHello(string name)
- {
- Console.WriteLine("Hello,{0}!", name);
- }
- }
- }
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- // Напишете метод, който при подадено име отпечатва на конзолата "Hello, <name>!" (например "Hello, Peter!")
- // Напишете програма, която тества дали този метод работи правилно.
- // Използвайте метод с параметър string
- static void Main(string[] args)
- {
- Console.Write("Please enter your name:");
- SayHello(Console.ReadLine());
- }
- static void SayHello(string name)
- {
- Console.WriteLine("Hello,{0}!", name);
- }
- }
- }
- using System;
- namespace Problem2
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Създайте метод GetMax() с два целочислени (int) параметъра, който ръща по-голямото от двете числа.
- // Напишете програма, която прочита три цели числа от конзолата и отпечатва най - голямото от тях, използвайки метода GetMax().
- // Използвайте свойството Max(a, b, c) = Max(Max(a, b), c).
- Console.Write("Please enter the first number:");
- int firstnum = int.Parse(Console.ReadLine());
- Console.Write("Please enter the second number:");
- int secondnum = int.Parse(Console.ReadLine());
- Console.Write("Please enter the third number:");
- int thirdnum = int.Parse(Console.ReadLine());
- GetMax(firstnum,secondnum,thirdnum);
- }
- static void GetMax(int number1, int number2, int number3)
- {
- if (number1 > number2&& number1>number3 )
- {
- Console.WriteLine("The first number is the biggest of all");
- }
- else if (number2 >number1&& number2> number3 )
- {
- Console.WriteLine("The second number is the biggest of all");
- }
- else if (number3 > number2 && number3 > number2)
- {
- Console.WriteLine("The third number is the biggest of all");
- }
- }
- }
- }
- using System;
- namespace Problem2
- {
- class Program
- { //Създайте метод GetMax() с два целочислени (int) параметъра, който ръща по-голямото от двете числа.
- // Напишете програма, която прочита три цели числа от конзолата и отпечатва най - голямото от тях, използвайки метода GetMax().
- // Използвайте свойството Max(a, b, c) = Max(Max(a, b), c).
- //static void Main(string[] args)
- //{
- // Console.WriteLine("Insert 3 numbers to compare them:");
- // int a = int.Parse(Console.ReadLine());
- // int b = int.Parse(Console.ReadLine());
- // int c = int.Parse(Console.ReadLine());
- // Console.Write("The bigest of three is: ");
- // Console.WriteLine(GetMax(GetMax(a, b), c));
- //}
- //static int GetMax(int a, int b)
- //{
- // return a > b ? a : b;
- //}
- //{
- static int a;
- static void GetMax(int first, int second)
- {
- if (first > second) a = first;
- else a = second;
- }
- static void
- Main(string[] args)
- {
- Console.Write("Enter first number: ");
- a = Int32.Parse(Console.ReadLine());
- Console.Write("Enter second number: ");
- int b = Int32.Parse(Console.ReadLine());
- Console.Write("Enter third number: ");
- int c = Int32.Parse(Console.ReadLine());
- GetMax(a, b);
- GetMax(a, c);
- Console.WriteLine("Biggest number is {0}", a);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement