Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Collections;
  11. using System.IO;
  12. namespace _15._42
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void Dialog_Click(object sender, EventArgs e)
  22. {
  23. openFileDialog1.ShowDialog();
  24. way.Text = openFileDialog1.FileName;
  25. }
  26.  
  27. private void button1_Click(object sender, EventArgs e)
  28. {
  29. Queue<Double> q1 = new Queue<Double>();
  30. StreamReader st = new StreamReader(way.Text);
  31. string[] arr = null;
  32. while (!st.EndOfStream)
  33. {
  34. string line = st.ReadLine();
  35. arr = line.Split('\n');
  36. for (int i = 0; i < arr.Length; i++)
  37. {
  38. Double prover;
  39. if (Double.TryParse(arr[i], out prover))
  40. q1.Enqueue(prover);
  41. }
  42. }
  43. st.Close();
  44.  
  45. int n = q1.Count;
  46. Double[] A = new Double[n];
  47. for (int i = 0; i < n; i++)
  48. {
  49. A[i] = q1.Dequeue();
  50. }
  51. Double s = 1;
  52. int j = n;
  53. for (int i = 0; i != n - 2; i++)
  54. {
  55. s = s * (A[i] + A[i + 1] + 2 * A[j]);
  56. j--;
  57. }
  58. result.Text += " " + Convert.ToString(s);
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement