結果

問題 No.3032 Unavailability of Inequality Signs
ユーザー chocoruskchocorusk
提出日時 2019-04-01 04:49:31
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 656 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 28,288 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-03 06:58:49
合計ジャッジ時間 4,888 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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: 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