오늘의 C# 공부 by 김윤정

using System;


 
////시프트 연산자
//namespace ShiftOperator
//{
//    class HelloWorld
//    {
//        static void Main()
//        {
//            Console.WriteLine("Testing <<....");

//            int a = 1;
//            Console.WriteLine("a     : {0:D5} (0x {0:X8})", a); //D는 10진수5는 자릿수, X는 16진수 8은 자릿수
//            Console.WriteLine("a << 1: {0:D5} (0x {0:X8})", a << 1); // 2진수인 데이터를 1칸 좌측으로 이동시켰다.
//            Console.WriteLine("a << 2: {0:D5} (0x {0:X4})", a << 2);
//            Console.WriteLine("a << 5: {0:D5} (0x {0:X8})", a << 5);


//            Console.WriteLine("\nTesting >> ... ");

//            int b = 255;
//            Console.WriteLine("b     : {0:D5} (0x {0:X8})", b);
//            Console.WriteLine("b >> 1: {0:D5} (0x {0:X8})", b >> 1);
//            Console.WriteLine("b >> 2: {0:D5} (0x {0:X8})", b >> 2);
//            Console.WriteLine("b >> 5: {0:D5} (0x {0:X8})", b >> 5);


//            Console.WriteLine("\nTesting >> 2... ");

//            int c = -255;
//            Console.WriteLine("c     : {0:D5} (0x {0:X8})", c);
//            Console.WriteLine("c >> 1: {0:D5} (0x {0:X8})", c >> 1);
//            Console.WriteLine("c >> 2: {0:D5} (0x {0:X8})", c >> 2);
//            Console.WriteLine("c >> 5: {0:D5} (0x {0:X8})", c >> 5);


//        }
//    }
//}

//// 비트 연산자 실습
//namespace BiteWiseOperator
//{
//    class HelloWorld
//    {
//        static void Main()
//        {
//            int a = 9;
//            int b = 10;

//            Console.WriteLine("{0}&{1}:{2}", a, b, a & b);
//            Console.WriteLine("{0}|{1}:{2}", a, b, a | b);
//            Console.WriteLine("{0}^{1}:{2}", a, b, a ^ b);

//            int c = 255;
//            Console.WriteLine("0~{0}(0x{0:X8}) : {1}(0x{1:X8})", c, ~c);
//        }
//    }
//}

////할당 연산자 실습
//namespace AssignmentOperator
//{
//    class HelloWorld
//    {
//        static void Main()
//        {
//            int a;
//            a = 100;
//            Console.WriteLine("a = 100 :{0}", a);

//            a += 90;
//            Console.WriteLine("a +=90 : {0}", a);

//            a -= 80;
//            Console.WriteLine("a -=80 : {0}", a);

//            a *= 70;
//            Console.WriteLine("a *= 70 : {0}", a);

//            a /= 60;
//            Console.WriteLine("a /= 60 : {0}", a);

//            a %= 50;
//            Console.WriteLine("a %= 50 : {0}", a);

//            a &= 40;
//            Console.WriteLine("a &= 40 : {0}", a);

//            a |= 30;
//            Console.WriteLine("a |= 30 : {0}", a);

//            a ^= 20;
//            Console.WriteLine("a ^= 20 : {0}", a);

//            a <<= 10;
//            Console.WriteLine("a <<= 10 :{0}", a);

//            a >>= 1;
//            Console.WriteLine("a >>= 1 : {0}", a);
//        }
//    }
//}


////분기문 연습
//namespace IFElse
//{
//    class HelloWorld
//    {
//        static void Main(string[] args)
//        {
//            Console.WriteLine("숫자를 입력하세요 :");

//            string input = Console.ReadLine();//문자열 입력을 받습니다
//            int number = Int32.Parse(input);//문자열 입력을 받아 숫자로 파싱했습니다

//            if (number < 0)
//                Console.WriteLine("음수인데다가");
//            else if (number > 0)
//                Console.WriteLine("일단 양수로 보이고");
//            else
//                Console.WriteLine("음수도 아니고 양수도 아니고 0이고");

//            if (number % 2 == 0)
//                Console.WriteLine("짝수이기도 함");
//            else
//                Console.WriteLine("홀수임");
//        }
//    }
//}

////if문 중첩해서 사용하기
//namespace IFIF
//{
//    class HelloWorld
//    {
//        static void Main(string[] args)
//        {
//            Console.Write("숫자를 입력하세요");

//            string input = Console.ReadLine();
//            int number = Convert.ToInt32(input);//

//            if (number > 0)
//            {
//                if (number % 2 == 0)
//                    Console.WriteLine("0보다 큰 짝수");
//                else
//                    Console.WriteLine("0보다 크고 홀수");
//            }
//            else
//            {
//                Console.WriteLine("0보다 작거나 같은 수");
//            }
//        }
//    }
//}


핑백

  • Kyudong lee (kyudong) | Pearltrees 2014-03-12 19:10:19 #

    ... Kyudong kyudong lee 대충 살아가는 게임개발자 : 오늘의 C# 공부 using System; D &gt;&gt; C &gt;&gt; book 제작 multi tool Processing ㄱ~ㅎ JQuery ... more



MyADD

<script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>