Sid.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace HTEXScan.Models
  5. {
  6. /**学生id数据**/
  7. class SidData
  8. {
  9. /**col**/
  10. public int Col
  11. {
  12. get;
  13. set;
  14. }
  15. /**值**/
  16. public char Text
  17. {
  18. get;
  19. set;
  20. }
  21. }
  22. /**学生id**/
  23. class Sid
  24. {
  25. /**max col**/
  26. private int maxCol = 0;
  27. /**学生id缓存数据**/
  28. private List<SidData> datas = new List<SidData>();
  29. /**添加**/
  30. public void Add(int col, char text)
  31. {
  32. SidData data = new SidData();
  33. data.Col = col;
  34. data.Text = text;
  35. this.datas.Add(data);
  36. if (col > maxCol)
  37. maxCol = col;
  38. }
  39. /**获取**/
  40. public List<string> Get()
  41. {
  42. List<string> ids = new List<string>();
  43. char[] dats = new char[maxCol];
  44. this.GetData(ids, dats, 1);
  45. return ids;
  46. }
  47. /**获取**/
  48. private void GetData(List<string> ids, char[] dats, int col)
  49. {
  50. if(col > this.maxCol)
  51. {
  52. ids.Add(new string(dats));
  53. }
  54. else
  55. {
  56. for(int i = 0;i < this.datas.Count;i++)
  57. {
  58. if (this.datas[i].Col == col)
  59. {
  60. dats[col - 1] = this.datas[i].Text;
  61. this.GetData(ids, dats, col + 1);
  62. }
  63. }
  64. }
  65. }
  66. }
  67. }