C#/수업 내용

[C#] 2021-08-24 오후

JSH1 2021. 8. 24. 16:35
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace hello_world
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(OddOrEven(Convert.ToInt32(Console.ReadLine())));
        }

        static string OddOrEven(int n)
        {
            if (n == 0)
            {
                return "오류";
            }

            else if (n % 2 == 0)
            {
                return "짝수";
            }

            else
            {
                return "홀수";
            }
        }

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace hello_world
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(JumpRope(Convert.ToInt32(Console.ReadLine())));
        }

        static int JumpRope(int n)
        {
            int check = 0;

            for(int i=0; i<n; i++)
            {
                Console.Write("줄넘기를 했습니다.   ");

                if ((i + 1) % 2 == 0) 
                {
                    check++;
                    Console.WriteLine(check);
                }

                else
                {
                    Console.WriteLine();
                }
            }

            return check;
        }

    }
}


'C# > 수업 내용' 카테고리의 다른 글

[C#] 2021-08-25 오후  (0) 2021.08.25
[C#] class  (0) 2021.08.25
[C#] Method  (0) 2021.08.24
[C#] 2021-08-24 오전  (0) 2021.08.24
[C#] 2021-08-23 오전  (0) 2021.08.23