Dive into Debug

  • 홈
  • 태그
  • 방명록

2025/08/07 2

[C#]숨어있는 숫자의 덧셈(1) - 복습 완료

개선 코드LINQ 버전using System;using System.Linq;public class Solution { public int solution(string my_string) { return my_string.Where(char.IsDigit).Sum(ch => ch - '0'); }}- Where(char.IsDigit) : char.IsDigit 메서드를 각 문자에 적용해서 숫자인 것만 필터링- Sum(ch => ch - '0') : 필터링된 각 char에 대해 ch - '0' 변환 후 합계 +) char.IsDigit(string, index) 사용해서 푼 버전* index가 필요하므로, foreach말고 for문 쓰 (가능하긴함)using System;usi..

C#/복습 완료 2025.08.07

[C#]문자 반복 출력하기 (프로그래머스) - (복습 완료)

개선 코드* Linqusing System;using System.Linq;public class Solution { public string solution(string my_string, int n) { return string.Concat(my_string.Select(ch => new string(ch, n))); }}.Select : 문자열의 각 문자(ch)를 변환ch => new string(ch, n) : 각 문자를 n번 반복한 문자열로 변환.Concat : 변환된 문자열을 하나로 합침 => 문자열의 각 문자를 -> 그 문자를 n번 반복한 문자열로 바꿔서 -> 모두 합쳐줘 cf. 다른 LINQ 방법return new string(my_string.SelectMany(c..

C#/복습 완료 2025.08.07
이전
1
다음
더보기
프로필사진

Dive into Debug

한계인 것 같을 때, 한 개만 더 하기

  • 분류 전체보기 (39)
    • C# (1)
      • 복습 완료 (5)
      • 복습 필요 (2)
    • 개발 (3)
      • Cursor (0)
      • Unity (0)
      • Git (0)
    • 공부 (0)
      • C# 공부 (1)
      • 유니티 공부 (0)
    • 책 (1)
    • 수영 (12)
      • 수영복 (6)
      • 수영장 (1)
      • 잡담 (3)
      • 수영 일기 (2)
    • 일상 (3)
    • 신비한 발견사전 (2)
    • 🎁 (5)
    • 비공개 (0)

Tag

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2025/08   »
일 월 화 수 목 금 토
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

방문자수Total

  • Today :
  • Yesterday :

Copyright © AXZ Corp. All rights reserved.

티스토리툴바