fork(1) download
  1. using System;
  2. using System.Linq;
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. // your code goes here
  8. string info="桃子*3,李子*2,葡萄*3,李子*3,葡萄*2,桃子*4";
  9. info = string.Join(",", info.Split(',').GroupBy(x => x.Split('*')[0]).Select(x => x.Key + "*" + x.Sum(y => int.Parse(y.Split('*')[1]))));
  10. Console.WriteLine(info);
  11. }
  12. }
Success #stdin #stdout 0s 29944KB
stdin
Standard input is empty
stdout
桃子*7,李子*5,葡萄*5