fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. // using System.Linq;
  5.  
  6. class Program
  7. {
  8. delegate void Operation();
  9.  
  10. static void Main(string[] args)
  11. {
  12. // присваивание адреса метода через контруктор
  13. Operation del = new Operation(First); // делегат указывает на метод Add
  14.  
  15. Console.WriteLine( del.Invoke());
  16.  
  17. del = Second; // теперь делегат указывает на метод Multiply
  18.  
  19. Console.WriteLine(del.Invoke());
  20.  
  21. Console.Read();
  22. }
  23. public static void First ()
  24. {
  25. double y, x, a;
  26.  
  27.  
  28. Console.WriteLine("Введите значение x:");
  29. x = int.Parse(Console.ReadLine());
  30. Console.WriteLine("Введите значение y:");
  31. y = int.Parse(Console.ReadLine());
  32.  
  33. a =(Math.Cos(x)/Math.PI-2*x)+16*x*Math.Cos(x*y)-2;
  34.  
  35. Console.WriteLine("a = "+ a);
  36.  
  37. }
  38. public static void Second ()
  39. {
  40. double r, p, h;
  41. r = p = h = 0;
  42. bool input = false;
  43. while (!input)
  44. {
  45. Console.WriteLine("Введите значение r:");
  46. r = int.Parse(Console.ReadLine());
  47. if (r >= 0)
  48. {
  49. input = true;
  50. }
  51. else
  52. {
  53. Console.WriteLine("r меньше нуля!");
  54. }
  55. }
  56.  
  57. input = false;
  58. while (!input)
  59. {
  60.  
  61. Console.WriteLine("Введите значение h:");
  62. h = int.Parse(Console.ReadLine());
  63. if (h >= 0)
  64. {
  65. input = true;
  66. }
  67. else
  68. {
  69. Console.WriteLine("h меньше нуля!");
  70. }
  71. }
  72.  
  73. p = 9.8 * r * h;
  74. Console.WriteLine("p = " + p);
  75.  
  76. }
  77.  
  78. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(15,17): error CS1502: The best overloaded method match for `System.Console.WriteLine(bool)' has some invalid arguments
/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
prog.cs(15,32): error CS1503: Argument `#1' cannot convert `void' expression to type `bool'
prog.cs(19,17): error CS1502: The best overloaded method match for `System.Console.WriteLine(bool)' has some invalid arguments
/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
prog.cs(19,31): error CS1503: Argument `#1' cannot convert `void' expression to type `bool'
Compilation failed: 4 error(s), 0 warnings
stdout
Standard output is empty