비교 연산자, if문, for문
2023. 7. 20.

using System;

namespace LearnDotnet
{
    
    internal class Program
    { 

        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            bool isSelectTerran = input == "테란";
            Console.WriteLine("테란을 선택했습니까? {0}", isSelectTerran);

            int hp = 10;
            int monsterDamage = 11;
            hp -= monsterDamage;
            bool isDead = hp <= 0;
            Console.WriteLine("isDead: {0}", isDead);
        }
    }
}

 

 

if문

 

if(부울 식){

}

 

for문

 

1번

using System;

namespace LearnDotnet
{
    
    internal class Program
    { 
      

        static void Main(string[] args)
        {
           for(int i=0; i<5; i++)
            {
                Console.WriteLine("줄넘기를 했습니다.");
            }
        }
    }
}

 

2번

using System;

namespace LearnDotnet
{
    
    internal class Program
    { 
      

        static void Main(string[] args)
        {
           for(int i=0; i<4; i++)
            {
                Console.WriteLine("줄넘기를 {0}회 했습니다.",i+1);
            }
        }
    }
}

3번

using System;

namespace LearnDotnet
{
    
    internal class Program
    { 
      

        static void Main(string[] args)
        {
           int num = 0;
           for(int i=0; i<3; i++)
            {
                Console.WriteLine("쌩쌩이를 했습니다.");
                //  i++;
                num = (i+1)*2;
            }

            Console.WriteLine("-------------------------");
            Console.WriteLine("줄넘기를 총 {0}회 했습니다.",num);
        }
    }
}

 

4번

using System;

namespace LearnDotnet
{
    
    internal class Program
    { 
      

        static void Main(string[] args)
        {
           int num = 0;
           for(int i=0; i<9; i++)
            {
                Console.WriteLine("2 x {0} = {1}",i+1,2*(i+1));
               
            }
        }
    }
}

myoskin