結果

問題 No.18 うーさー暗号
ユーザー Klay
提出日時 2017-04-21 23:10:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 665 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 55,508 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 06:28:57
合計ジャッジ時間 869 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

char L[26];

void setAlphabet(void)
{
	int a = 65;

	for(int i = 0; i < 26; i ++)
	{
		L[i] = (char)(a + i);
	}
}

char getNextAlphabet(char A, int n) //A=65, Z=90
{
	int m = n;
	int l = (int)A - 65;
	
	for(;m >= 26;)
	{
		m = m - 26;
	}
	
	if(l - m < 0)
	{
		return L[26 + l - m];
	}
	else
	{
		return L[l - m];
	}
}

int main(void)
{
	setAlphabet();

	std::string S;

	std::cin >> S;
	
	int count = S.size();
	
	char alpha[count];
	
	for(int i = 0; i < count; i ++)
	{
		alpha[i] = S[i];
	}
	
	for(int i = 1; i <= count; i ++)
	{	
		std::cout << getNextAlphabet(alpha[i - 1], i);
	}
	
	std::cout << std::endl;

	return 0;
}
0