
https://www.acmicpc.net/problem/2744
입력으로 주어진 문자열에서 대문자는 소문자로, 소문자는 대문자로 바꿔 출력하는 문제.
foreach로 문자열을 순회하면서 char.IsUpper()를 이용해 대소문자를 판별하고, 삼항 연산자를 써서 바꿔줬다.
처음에 삼항 연산자가 기억이 잘 안 났는데 조건 ? 참일 때 값 : 거짓일 때 값 형태라는 걸 다시 떠올림.
using System;
using System.Collections.Generic;
using System.Text;
namespace backjoon
{
internal class Program
{
static void Main(string[] args)
{
var input = Console.ReadLine();
string output = string.Empty;
foreach (var c in input)
{
output += char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c);
}
Console.WriteLine(output);
}
}
}