anon20016

Строки

Jan 18th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string s = System.IO.File.ReadAllText(@"data.txt");
  14. s += " ";
  15. string t = "";
  16. string n = "";
  17. for (int i = 0;i < s.Length; i++)
  18. {
  19. if(s[i] == '.')
  20. {
  21. t += ",";
  22. }
  23. else
  24. {
  25. t += s[i];
  26. }
  27. }
  28.  
  29. double[,] a = new double[1000, 3];
  30. int x = 0;
  31. int y = 0;
  32. for(int i = 0;i < t.Length;i++)
  33. {
  34. if (t[i] >= '0' && t[i] <= '9' || t[i] == ',')
  35. {
  36. n += t[i];
  37. }
  38. else
  39. {
  40. if (n.Length != 0)
  41. {
  42. a[x, y] = Convert.ToDouble(n);
  43. y++;
  44. if (y == 3)
  45. {
  46. y = 0;
  47. x++;
  48. }
  49. n = "";
  50. }
  51. }
  52. }
  53. for (int i = 0; i < x; i++)
  54. {
  55. Console.Write(a[i, 0]);
  56. Console.Write(" ");
  57. Console.Write(a[i, 1]);
  58. Console.Write(" ");
  59. Console.WriteLine(a[i, 2]);
  60. }
  61.  
  62.  
  63. Console.ReadKey();
  64. }
  65. }
  66. }
Add Comment
Please, Sign In to add comment