結果

問題 No.3032 Unavailability of Inequality Signs
ユーザー chocoruskchocorusk
提出日時 2019-04-01 04:49:31
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 656 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 27,368 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-15 20:16:10
合計ジャッジ時間 5,198 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 OLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘solve’ 内:
main.c:3:5: 警告: 関数 ‘sprintf’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    3 |     sprintf(sa, "%d", a);
      |     ^~~~~~~
main.c:1:1: 備考: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
  +++ |+#include <stdio.h>
    1 | int solve(int a, int b){
main.c:3:5: 警告: 組み込み関数 ‘sprintf’ の互換性がない暗黙的な宣言です [-Wbuiltin-declaration-mismatch]
    3 |     sprintf(sa, "%d", a);
      |     ^~~~~~~
main.c:3:5: 備考: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
main.c:5:12: 警告: 関数 ‘strlen’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    5 |     int na=strlen(sa), nb=strlen(sb);
      |            ^~~~~~
main.c:1:1: 備考: include ‘<string.h>’ or provide a declaration of ‘strlen’
  +++ |+#include <string.h>
    1 | int solve(int a, int b){
main.c:5:12: 警告: 組み込み関数 ‘strlen’ の互換性がない暗黙的な宣言です [-Wbuiltin-declaration-mismatch]
    5 |     int na=strlen(sa), nb=strlen(sb);
      |            ^~~~~~
main.c:5:12: 備考: include ‘<string.h>’ or provide a declaration of ‘strlen’
main.c:7:16: 警告: 関数 ‘strcmp’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    7 |         return strcmp(sa, sb);
      |                ^~~~~~
main.c:7:16: 備考: include ‘<string.h>’ or provide a declaration of ‘strcmp’
main.c: 関数 ‘main’ 内:
main.c:15:12: 警告: 関数 ‘scanf’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   15 |     int n; scanf("%d", &n);
      |            ^~~~~
main.c:15:12: 備考: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:15:12: 警告: 組み込み関数 ‘scanf’ の互換性がない暗黙的な宣言です [-Wbuiltin-declaration-mismatch]
main.c:15:12: 備考: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:20:13: 警告: 

ソースコード

diff #

int solve(int a, int b){
    char sa[100]={'\0'}, sb[100]={'\0'};
    sprintf(sa, "%d", a);
    sprintf(sb, "%d", b);
    int na=strlen(sa), nb=strlen(sb);
    if(na==nb){
        return strcmp(sa, sb);
    }else{
        return solve(na, nb);
    }
}
int main()
{
    char c1='0'+12, c2='0'+14;
    int n; scanf("%d", &n);
    while(n){
        int a, b; scanf("%d %d", &a, &b);
        int cmp=solve(a, b);
        if(cmp==0){
            printf("=\n");
            continue;
        }
        char s[100]={'\0'};
        sprintf(s, "%d", cmp);
        if(s[0]=='-') printf("%c\n", c1);
        else printf("%c\n", c2);
        n--;
    }
    return 0;
}
0