結果

問題 No.327 アルファベット列
ユーザー ghasshee
提出日時 2016-01-01 03:32:59
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-06 22:35:58
合計ジャッジ時間 1,816 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘loop’:
main.c:29:18: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
   29 |         printf("%c",'A'+n%26);
      |                 ~^  ~~~~~~~~
      |                  |     |
      |                  int   long int
      |                 %ld
main.c:31:18: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
   31 |         printf("%c",'A'+n);
      |                 ~^  ~~~~~
      |                  |     |
      |                  int   long int
      |                 %ld
main.c: In function ‘main’:
main.c:37:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |     scanf("%ld",&n);
      |     ^~~~~~~~~~~~~~~

ソースコード

diff #

/*
 * this is the program which  
 * convert NUM to STRING
 * 
 *     0  ...  25    
 *     A  ...   Z    
 * 
 *    26  ...  51  <-- INPUT
 *    AA  ...  AZ  <-- OUTPUT
 * 
 *    ..  ...  ..
 * 
 *   676  ... 701
 *    ZA  ...  ZZ
 *
 *   702  ...
 *   AAA  ...
 */


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

void loop(long n)
{
    if (n>25){
        loop(n/26-1);
        printf("%c",'A'+n%26);
    }else 
        printf("%c",'A'+n);
}

int main( )
{
    long n;
    scanf("%ld",&n);
    loop(n);
    printf("\n");
    
    return 0;
}
0