結果

問題 No.18 うーさー暗号
ユーザー Maeda
提出日時 2025-03-07 09:33:21
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 25,856 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2025-03-07 09:33:22
合計ジャッジ時間 1,041 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int CharConversion(int charNum){
	int conversionNumber = charNum - 65;
	while(conversionNumber < 0 ){
		conversionNumber += 26;
	}
	return conversionNumber + 65;
}

void main(){
	char str[10000] = "a";
	int inputStr = scanf("%s",str);
	if(inputStr == 2){
		printf("strの入力ミス\n");
	}

	for(int i = 0 ; i < 10000; i++){
		if(str[i] == '\0'){
			break;
		}
		int asciiValue = (int)str[i]-i-1; // キャストを用いて数値に変換
		if(asciiValue < (int)'A'){
			asciiValue = CharConversion(asciiValue);
		}
		printf("%c",(char)asciiValue);
	}
}
0