#include <iostream>
using namespace std;
int main()
{
char ch;
cin >> ch;
cout << (int)ch;
}
#include <iostream>
using namespace std;
int main()
{
int N, sum = 0;
char ch;
cin >> N; //숫자의 개수
for (int i = 0; i < N; i++)
{
cin >> ch;
sum += (ch - '0');
}
cout << sum;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
string S;
string abc = "abcdefghijklmnopqrstuvwxyz";
cin >> S;
for (int i = 0; i < abc.length(); i++)
{
cout << (int)S.find(abc[i]) << "\n";
}
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
int T, R;
string S;
cin >> T;
for (int i = 0; i < T; i++)
{
cin >> R;
cin >> S;
for (char ch : S)
{
for (int j = 0; j < R; j++)
{
cout << ch;
}
}
cout << "\n";
}
}
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string str;
int max = 0;
int count = 0;
int X;
cin >> str;
int abc[26] = { 0 }; //a-z count 할 배열
transform(str.begin(), str.end(), str.begin(), (int(*)(int))tolower);
//string의 모든 문자를 소문자로 변환
for (int i = 0; i < str.length(); i++)
{
abc[str[i] - 97]++;
}
for (int i = 0; i < 26; i++)
{
if (abc[i] > max)
{
max = abc[i];
X = i;
count = 0;
}
if (max == abc[i])
{
count++;
}
}
if (count > 1)
{
cout << "?";
}
else
{
cout << (char)(X + 65);
}
}
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string S;
getline(cin, S);
int cnt = 0;
for (int i = 0; i < S.length(); i++)
{
if (S[i] == ' ') {
cnt++;
}
}
if (S[0] == ' ')
cnt--;
if (S[S.length() - 1] == ' ')
cnt--;
cout << cnt+1;
return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string A, B;
cin >> A >> B;
reverse(A.begin(), A.end()); //문자열을 거꾸로 저장
reverse(B.begin(), B.end());
if (A > B)
cout << stoi(A); //string to int
else
cout << stoi(B);
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
string S;
int sum = 0;
cin >> S;
for (int i = 0; i < S.length(); i++)
{
if (S[i] < 'P')
{
sum += (S[i] - 'A') / 3 + 3;
}
else if (S[i] >= 'P' && S[i] < 'T')
{
sum += 8;
}
else if (S[i] >= 'T' && S[i] < 'W')
{
sum += 9;
}
else
sum += 10;
}
cout << sum;
return 0;
}
//풀이방법 암기
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
//Vector 사용
//String의 find 사용, replace 사용
string S;
int idx;
vector<string> crotia = { "c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="};
cin >> S;
for (int i = 0; i < crotia.size(); i++)
{
while (1)
{
idx = S.find(crotia[i]);
if (idx == string::npos) //find() 함수에 의해서 found 되지 못하는 경우 npos값이 리턴
break;
S.replace(idx, crotia[i].length(), "#");
}
}
cout << S.length();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
int N, count = 0;
bool hit;
string S;
cin >> N;
for (int i = 0; i < N; i++)
{
cin >> S;
hit = true;
for (int j = 0; j < S.length(); j++)
{
for (int k = 0; k < j; k++)
{
if (S[j] == S[k] && S[j] != S[j-1])
{
hit = false;
break;
}
}
}
if (hit)
{
count++;
}
}
cout << count;
return 0;
}