結果

問題 No.18 うーさー暗号
ユーザー KlayKlay
提出日時 2017-04-21 23:10:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 665 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 52,868 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 12:41:44
合計ジャッジ時間 1,039 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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