[백준] C# : 5의 수난 (23037번)

ssu_hyun·2022년 7월 26일
0

Data Structure & Algorithm

목록 보기
39/67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Baekjoon
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            double result = 0;
            foreach (char c in s)
            {
                double n = (int)Char.GetNumericValue(c);
                result += Math.Pow(n, 5);
            }
            Console.WriteLine(result);
        }
    }
}
  • ~.Parse(string)
  • public static double GetNumericValue (char c);
    • 문자가 숫자를 나타내는 경우에는 c의 숫자 값을 반환하고 그렇지 않은 경우에는 -1.0을 반환
  • Math.Pow(double x, double n) : n의 n승 제곱

0개의 댓글