結果
| 問題 | No.536 人工知能 | 
| コンテスト | |
| ユーザー |  Elk | 
| 提出日時 | 2018-05-28 23:53:31 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 1,000 ms | 
| コード長 | 558 bytes | 
| コンパイル時間 | 138 ms | 
| コンパイル使用メモリ | 23,808 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-30 07:54:16 | 
| 合計ジャッジ時間 | 786 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 | 
コンパイルメッセージ
main.cpp: In function ‘int check_abc_pos(char)’:
main.cpp:14:1: warning: control reaches end of non-void function [-Wreturn-type]
   14 | }
      | ^
main.cpp: In function ‘int main()’:
main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |     scanf("%s", id);
      |     ~~~~~^~~~~~~~~~
main.cpp:28:25: warning: ‘%s’ directive writing 3 bytes into a region of size between 1 and 20 [-Wformat-overflow=]
   28 |         sprintf(str, "%s%s", id, "-AI");
      |                         ^~       ~~~~~
In file included from /usr/include/stdio.h:894,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:38:34: note: ‘__builtin___sprintf_chk’ output between 4 and 23 bytes into a destination of size 20
   38 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   39 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   40 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
#include <string.h>
char ABC[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int check_abc_pos(char a){
    char c;
    for(c = 'a'; c <= 'z'; c++){
        if(c == a){
            return (c - 'a');
        }
    }
}
int main(){
    char id[20], str[20];
    int len;
    scanf("%s", id);
    len = strlen(id);
    if(id[len - 2] == 'a' && id[len - 1] == 'i'){
        id[len - 2] = 'A';
        id[len - 1] = 'I';
        printf("%s\n", id);
    }else{
        sprintf(str, "%s%s", id, "-AI");
        printf("%s\n", str);
    }
    return 0;
}
            
            
            
        