Guest User

Untitled

a guest
Jan 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. Task("LinqObj87");
  2. var A = File.ReadAllLines(GetString(), Encoding.Default);
  3. var D = File.ReadAllLines(GetString(), Encoding.Default);
  4. var E = File.ReadAllLines(GetString(), Encoding.Default);
  5.  
  6. var AA = A.Select(e =>
  7. {
  8. var s = e.Split(' ');
  9. return new
  10. {
  11. year_b = s[0],
  12. street = s[1],
  13. code_potr = s[2]
  14. };
  15. }).OrderBy(x=>x.street);
  16.  
  17. var DD = D.Select(e =>
  18. {
  19. var s = e.Split(' ');
  20. return new
  21. {
  22. art_good = s[0],
  23. shop = s[1],
  24. price_good = int.Parse(s[2])
  25. };
  26. });
  27.  
  28. var EE = E.Select(e =>
  29. {
  30. var s = e.Split(' ');
  31. return new
  32. {
  33. shop = s[0],
  34. code_potr = s[1],
  35. art_good = s[2]
  36. };
  37. });
  38.  
  39. var res= AA.Join(EE.GroupJoin(DD,q=>q.shop+q.art_good,w=>w.shop+w.art_good,(q,ww)=>new
  40. {
  41. code_potr=q.code_potr,
  42. shop=q.shop,
  43. s=ww.Select(x=>x.price_good).Sum()
  44. }), x => x.code_potr, y => y.code_potr,(x,y)=>$"{x.street} {y.shop} {y.s}").Distinct();
  45.  
  46. var rr = AA.Join(EE, x => x.code_potr, y => y.code_potr, (x, y) => new
  47. {
  48. str=x.street,
  49. sh=y.shop,
  50. art=y.art_good
  51. });
  52.  
  53. var pp = rr.GroupJoin(DD, q => q.sh + q.art, w => w.shop + w.art_good, (q, ww) => new
  54. {
  55. street=q.str,
  56. shop=q.sh,
  57. s=ww.Where(x=>x.shop==q.sh && x.art_good==q.art).Select(x=>x.price_good).Sum()
  58. }).Distinct();
  59.  
  60. var kk = pp.GroupBy(x => x.street +" "+x.shop, (key, value) => new
  61. {
  62. var s = key.Split(' '),
  63. street=s[0],
  64.  
  65. //street =key,
  66. sum=value.Where(x=>x.street+x.shop==key).Select(g=>g.s).Sum(),
  67.  
  68. streetr=value.Where(x => x.street + " " + x.shop == key).Select(g=>g.street),
  69. shopr= value.Where(x => x.street + " " + x.shop == key).Select(g => g.shop)
  70. }).Select(x=>x.streetr+" "+x.shopr+" "+x.sum).Show();
Add Comment
Please, Sign In to add comment