Advertisement
Guest User

Untitled

a guest
Jun 12th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace T_1G
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Random rnd = new Random();
  13.  
  14. int n = 5000;
  15.  
  16. Console.BufferWidth = (int)Math.Max(Math.Min((long)(100) * 6 + 10, (long)(n) * 6 + 10), 100);
  17. Console.WindowWidth = 100;
  18. Gauss g = new Gauss(n);
  19. for (int h = 0; h < 100; h++)
  20. {
  21. for (int i = 0; i < n; i++)
  22. {
  23. for (int j = 0; j < n; j++)
  24. {
  25. g.a[i, j] = rnd.Next(-10, 10);
  26. }
  27. }
  28. for (int i = 0; i < n; i++)
  29. {
  30. g.f[i] = 0;
  31. for (int j = 0; j < n; j++)
  32. {
  33. g.f[i] += g.a[i, j];
  34. }
  35. }
  36. if(n <= 100)for (int i = 0; i < n; i++)
  37. {
  38. for (int j = 0; j < n; j++)
  39. {
  40. Console.Write(String.Format("{0,6:0.00}", g.a[i, j]));
  41. }
  42. Console.WriteLine(String.Format("{0,8:0.00}", g.f[i]));
  43. }
  44. int r = g.Calc();
  45. Console.WriteLine();
  46. if (r == 1)
  47. {
  48. Console.WriteLine("Error");
  49. }
  50. else
  51. {
  52. if (n <= 100) for (int i = 0; i < n; i++)
  53. {
  54. for (int j = 0; j < n; j++)
  55. {
  56. Console.Write(String.Format("{0,5:0.00}", g.a[i, j]));
  57. }
  58. Console.WriteLine(String.Format("{0,7:0.00}", g.f[i]));
  59. }
  60. double delta = 0;
  61. for (int i = 0; i < n; i++) delta += Math.Abs(1 - g.f[i]);
  62. Console.WriteLine(String.Format("{0,15:0.000000000000}", delta));
  63. }
  64. Console.ReadKey();
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement