結果

問題 No.8032 Unavailability of Inequality Signs
ユーザー chocoruskchocorusk
提出日時 2019-04-01 04:49:31
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 656 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 27,776 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-11-24 04:51:30
合計ジャッジ時間 11,758 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 OLE -
testcase_05 WA -
testcase_06 OLE -
testcase_07 OLE -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'solve':
main.c:3:5: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration]
    3 |     sprintf(sa, "%d", a);
      |     ^~~~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'sprintf'
  +++ |+#include <stdio.h>
    1 | int solve(int a, int b){
main.c:3:5: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch]
    3 |     sprintf(sa, "%d", a);
      |     ^~~~~~~
main.c:3:5: note: include '<stdio.h>' or provide a declaration of 'sprintf'
main.c:5:12: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
    5 |     int na=strlen(sa), nb=strlen(sb);
      |            ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen'
  +++ |+#include <string.h>
    1 | int solve(int a, int b){
main.c:5:12: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
    5 |     int na=strlen(sa), nb=strlen(sb);
      |            ^~~~~~
main.c:5:12: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:7:16: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
    7 |         return strcmp(sa, sb);
      |                ^~~~~~
main.c:7:16: note: include '<string.h>' or provide a declaration of 'strcmp'
main.c: In function 'main':
main.c:15:12: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   15 |     int n; scanf("%d", &n);
      |            ^~~~~
main.c:15:12: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:15:12: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
main.c:15:12: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:20:13: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   20 |             printf("=\n");
      |             ^~~

ソースコード

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