結果

問題 No.18 うーさー暗号
ユーザー sasa
提出日時 2025-03-04 15:54:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 325 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 27,392 KB
実行使用メモリ 8,612 KB
最終ジャッジ日時 2025-03-04 15:54:13
合計ジャッジ時間 1,566 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:12: warning: format not a string literal and no format arguments [-Wformat-security]
   18 |     printf(arr);
      |            ^~~
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%s", arr);
      |     ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

char cast(char c, int i){
    c -= 'Z';
    c = ( c-i-1 ) % 26;
    c += 'Z';
    return c;
}

int main(){
    int len = 1024;
    char arr[len];
    scanf("%s", arr);
    for(int i=0; i<len; i++){
        if(arr[i] == '\0') break;
        arr[i] = cast(arr[i], i);
    }
    printf(arr);

    return 0;
}
0