fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. internal class Square
  5. {
  6. //public static double Xposition=0;
  7. private double m_S;
  8. private double m_PX = 0;
  9. private double m_PY = 0;
  10.  
  11. public Square(double p_S)
  12. {
  13. m_S = p_S;
  14. }
  15.  
  16. public void SetXPosition(double p_PX)
  17. {
  18. m_PX = p_PX;
  19. }
  20.  
  21. public void SetYPosition(double p_PY)
  22. {
  23. m_PY = p_PY;
  24. }
  25.  
  26. public double GetSide()
  27. {
  28. return m_S;
  29. }
  30.  
  31.  
  32. public static void OrganiseSquares(ref List<Square> pio_Squares)
  33. {
  34.  
  35. for(int j=pio_Squares.Count-1;j>0;j--)
  36. {
  37. for(int i=1; i<pio_Squares.Count;i++)
  38. {
  39. Square temp=null;
  40. if(pio_Squares[i].GetSide()<pio_Squares[i-1].GetSide())
  41. {
  42. temp=pio_Squares[i];
  43. pio_Squares[i]=pio_Squares[i-1];
  44. pio_Squares[i-1]=temp;
  45. }
  46.  
  47. }
  48. }
  49. for(int i=0;i<pio_Squares.Count;i++)
  50. {
  51.  
  52. Square s=new Square(pio_Squares[i].m_S);
  53. //s.m_PX=Xposition;
  54. s.SetXPosition((pio_Squares[i-1].m_XP)+s.GetSide());
  55. s.SetYPosition(s.m_PY);
  56. Console.WriteLine(s.m_PX+""+s.m_PY);
  57. //Xposition+=s.GetSide();
  58. }
  59. }
  60. }
  61. class mainclass
  62. {
  63. public static void Main()
  64. {
  65. var listOfSquares = new List<Square>{
  66. new Square(3),new Square(1),new Square(8),new Square(5)};
  67.  
  68. Square.OrganiseSquares(ref listOfSquares);
  69. }}
Compilation error #stdin compilation error #stdout 0.04s 23952KB
stdin
Standard input is empty
compilation info
prog.cs(49,29): error CS1061: Type `System.Collections.Generic.List<Square>' does not contain a definition for `length' and no extension method `length' of type `System.Collections.Generic.List<Square>' could be found. Are you missing an assembly reference?
/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
prog.cs(54,36): error CS1061: Type `Square' does not contain a definition for `m_XP' and no extension method `m_XP' of type `Square' could be found. Are you missing an assembly reference?
prog.cs(4,16): (Location of the symbol related to previous error)
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty