結果

問題 No.8032 Unavailability of Inequality Signs
ユーザー chocoruskchocorusk
提出日時 2019-04-01 04:51:47
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 27,904 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 04:54:32
合計ジャッジ時間 732 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 1 ms
5,248 KB
testcase_05 AC 1 ms
5,248 KB
testcase_06 AC 1 ms
5,248 KB
testcase_07 AC 1 ms
5,248 KB
testcase_08 AC 1 ms
5,248 KB
testcase_09 AC 1 ms
5,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:21:13: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   21 |             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){
        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);
    }
    return 0;
}
0