숫자 제외하고 , 알파벳 소문자, 대문자일 경우에 + 13
Z, z 초과하면 앞으로 이동해서 카운팅
조건 처리를 잘 해야함.
대문자 소문자를 분류 해서 진행함.
using namespace std;
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
int main()
{
string s;
getline(cin, s);
for (auto &iter : s)
{
if (iter == ' ')
continue;
// 대문자와 소문자를 구별해야 함.
if (iter >= 'a' && iter <= 'z')
{
if (iter + 13 > 'z')
{
int n = 'z' - iter;
iter = 'a' + 13 - n - 1;
}
else
iter += 13;
}
else if (iter >= 'A' && iter <= 'Z')
{
if (iter + 13 > 'Z')
{
int n = 'Z' - iter;
iter = 'A' + 13 - n - 1;
}
else
iter += 13;
}
// 숫자는 그냥 그대로
}
cout << s;
}
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <list>
#include <deque>
#include <map>
int main()
{
//abcdefghijklm nopqrstuvwxyz
//nopqrstuvwxyz abcdefghijklm
//map<char, char>m =
//{ { 'a' , 'n' }, { 'b' , 'o' } , {'c' ,'p'} , {'d' ,'q'}
//, {'e' ,'r'} , {'f' ,'s'} , {'g' ,'t'} , {'h' ,'u'}
//, {'i' ,'v'} , {'j' ,'w'} , {'k' ,'x'} , {'l' ,'y'}
//, {'m' ,'z'} , {'n' ,'a'} , {'o' ,'b'} , {'p' ,'c'}
//, {'q' ,'d'} , {'r' ,'e'} , {'s' ,'f'} , {'t' ,'g'}
//, {'u' ,'h'} , {'v' ,'i'} , {'w' ,'j'} , {'x' ,'k'}
//, {'y' ,'l'} , {'z' ,'m'}
//, { 'A' , 'N' }, { 'B' , 'O' } , {'C' ,'P'} , {'D' ,'Q'}
//, {'E' ,'R'} , {'F' ,'S'} , {'G' ,'T'} , {'H' ,'U'}
//, {'I' ,'V'} , {'J' ,'W'} , {'K' ,'X'} , {'L' ,'Y'}
//, {'M' ,'Z'} , {'N' ,'A'} , {'O' ,'B'} , {'P' ,'C'}
//, {'Q' ,'D'} , {'R' ,'E'} , {'S' ,'F'} , {'T' ,'G'}
//, {'U' ,'H'} , {'V' ,'I'} , {'W' ,'J'} , {'X' ,'K'}
//, {'Y' ,'L'} , {'X' ,'M'} };
string word;
getline(cin, word);
string ss = "";
for (auto iter : word)
{
// 문자열일 때와 숫자일 때를 구별해야 함.
if (('a' <= iter && 'z' >= iter)
|| ('A' <= iter && 'Z' >= iter)
)
{
// 소문자인데 ,,, n 부터 z일 경우에
if (('n' <= iter && 'z' >= iter)
|| ('N' <= iter && 'Z' >= iter))
{
ss += iter - 13;
}
// 대문자인데 ,,, N 부터 Z일 경우에.
//else if (('N' <= iter && 'Z' >= iter))
//{
// ss += iter - 13;
//
//}
else
{
ss += iter + 13;
}
}
else
{
ss += iter;
}
// n 부터는 a가 나와야 함.
//if(iter > '')
}
cout << ss;
}