結果

問題 No.39 桁の数字を入れ替え
コンテスト
ユーザー mamo_ICE
提出日時 2022-12-22 18:49:03
言語 C90(gcc15)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 415 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 159 ms
コンパイル使用メモリ 37,624 KB
最終ジャッジ日時 2026-02-24 01:11:40
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:7:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
    7 |     gets(num);
      |     ^~~~
In file included from main.c:1:
/usr/include/stdio.h:667:14: note: declared here
  667 | extern char *gets (char *__s) __wur __attribute_deprecated__;
      |              ^~~~
/usr/bin/ld: /tmp/cc6pd6IC.o: in function `main':
main.c:(.text.startup+0xf): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #
raw source code

#include <stdio.h>

int main(void){
    int i, tmp, idx;
    char num[10];
    
    gets(num);
    if(num[0] == '9') printf("%s\n", num);
    else{
        tmp = 0;
        for(i=0; num[i]; i++){
            if(num[i] >= tmp){
                tmp = num[i];
                idx = i;
            }
        }
        num[idx] = num[0];
        num[0] = tmp;
        printf("%s\n", num);
    }
    
    return 0;
    
}
0