예제 #1
0
 public Student(int i, string n, int a, int p)
 {
     id = i;
     name = n;
     age = a;
     per = p;
     next = null;
 }
예제 #2
0
 public Student()
 {
     id = 0;
     name = "";
     age = 0;
     per = 0;
     next = null;
 }
예제 #3
0
파일: main.cs 프로젝트: prijuly2000/Dot-Net
        public static void Main()
        {
            string ch="y";
            int choice,index;
            int size, i;
            MyCollege c = new MyCollege();
            while(ch=="y" || ch=="Y")
            {
                Console.WriteLine("----ops----");
                Console.WriteLine("1.Create list");
                Console.WriteLine("2.Insert student");
                Console.WriteLine("3.Display");
                Console.WriteLine("4.Delete student");
                Console.WriteLine("Enter the choice");
                choice=int.Parse(Console.ReadLine());
                switch(choice)
                {
                    case 1:
                        Console.WriteLine("Enter the size:");
                        size=int.Parse(Console.ReadLine());

                        Console.WriteLine("-----Students Info-----");
                        for (i = 0; i < size; i++)
                        {
                            Student s1 = new Student();
                            s1.accept();
                            c[i] = s1;
                        }
                        break;
                    case 2:
                        Console.WriteLine("New student");
                        Student s=new Student();
                        s.accept();
                        Console.WriteLine("Enter the index");
                        index=int.Parse(Console.ReadLine());
                        c[index]=s;
                        break;
                    case 3:
                        Console.WriteLine(c);
                        break;
                    case 4:
                        Console.WriteLine("Enter the student to delete");
                        index=int.Parse(Console.ReadLine());
                        Student s2=c[index];
                        Console.WriteLine("Deleted student");
                        Console.WriteLine(s2);
                        break;
                }
                Console.WriteLine("Wanna conti(y/n)");
                ch=Console.ReadLine();
            }
            Console.ReadLine();
        }
예제 #4
0
        public Student this[int index]
        {
            set
            {
                Student temp = value;
                if(index==0 || start==null)
                {
                    temp.NEXT = start;
                    start = temp;
                    temp = null;
                    return;
                }
                int i=1;
                Student p = start;
                while (p.NEXT != null)
                {
                    if (i == index-1 )
                    {
                        temp.NEXT = p.NEXT;
                        p.NEXT = temp;
                        temp = null;
                        return;
                    }

                    i++;
                    p = p.NEXT;
                }
                p.NEXT = temp;
                temp = null;

            }

            get
            {
                if (start == null)
                {
                    return null;
                }

                if (index == 0)
                {
                    Student p = start;
                    start = start.NEXT;
                    return p;
                }
                int i=1;
                Student p1 = start;
                while (p1 != null)
                {
                    if (i == index-1)
                    {
                        Student q = p1.NEXT;
                        p1.NEXT = q.NEXT;
                        return q;
                    }
                    i++;
                    p1=p1.NEXT;
                }
                return null;
            }
        }
예제 #5
0
 public MyCollege()
 {
     start = null;
 }