結果

問題 No.1883 SLASH
ユーザー mamo_ICEmamo_ICE
提出日時 2022-12-28 21:09:57
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 20,480 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 02:54:54
合計ジャッジ時間 1,038 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 0 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:5: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
    8 |     gets(str);
      |     ^~~~
      |     fgets
/usr/bin/ld: /tmp/ccnF1M6e.o: in function `main':
main.c:(.text.startup+0x1e): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #

#include <stdio.h>
#define toi(c) (c-'0')

int main(void){
    char str[4];
    int max, min;
    
    gets(str);
    if(str[0] < str[1])
        if(str[1] < str[2]){  // str[0] < str[1] < str[2]
            min = 0;
            max = 2;
        }else if(str[0] < str[2]){  // str[0] < str[2] < str[1]
            min = 0;
            max = 1;
        }else{  // str[2] < str[0] < str[1]
            min = 2;
            max = 1;
        }
    else  // str[1] < str[0]
        if(str[0] < str[2]){  // str[1] < str[0] < str[2]
            min = 1;
            max = 2;
        }else if(str[1] < str[2]){  // str[1] < str[2] < str[0]
            min = 1;
            max = 0;
        }else{  // str[2] < str[1] < str[0]
            min = 2;
            max = 0;
        }
    printf("%d\n", toi(str[max])-toi(str[min]));
    
    return 0;
}
0