コード例 #1
0
        static void Main(string[] args)
        {
            //과제4 : push(), removeat(), clear(), outstring(), removeatsize(stindex, endindex).
            //프로그래밍기초_2A_과제4_이름.zip.
            //insertat(int p_index, int p_val); aa.insertat()
            //addrange(int p_index, int[] p_val);
            //count(프로퍼티 방식).
            //예외사항 발생.
            vectorint aa = new vectorint();

            aa.push(10);
            aa.push(20);
            aa.push(30);
            aa.insertat(1, 5);     //10, 5, 20, 30;
            int[] a = { 1, 2, 3 };
            aa.addrange(1, a);     //10, 1, 2, 3, 5, 20, 30;
            aa.outstring();        //10, 1, 2, 3, 5, 20, 30;
            Console.WriteLine("size : {0}", aa.count());
            aa.removeat(1);        //10, 2, 3, 5, 20, 30;
            aa.removeatsize(1, 3); //10, 20, 30;
            aa.outstring();
            Console.WriteLine("size : {0}", aa.count());
            aa.clear();
            aa.outstring(); //empty
            Console.WriteLine("size : {0}", aa.count());
            aa.addrange(0, a);
            aa.removeat(4);        //error;
            aa.removeatsize(1, 3); //error;
            aa.outstring();        //1.
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //과제 1.
            string tempstr  = null;
            string tempstr2 = "";
            bool   isflag1  = tempstr.isempty();  //true나 false 호출.
            bool   isflag2  = tempstr2.isempty(); //true나 false 호출.

            Console.WriteLine("tempstr = {0}", isflag1);
            Console.WriteLine("tempstr2 = {0}\n", isflag2);

            //과제 2.
            vectorint aa = new vectorint();

            aa.push(10);
            aa.push(20);
            aa.push(30);
            aa.outstring(); //10, 20, 30
            aa.removeat(1);
            aa.outstring(); //10, 30
            aa.clear();
            aa.outstring(); //empty
        }