結果

問題 No.293 4>7の世界
ユーザー lonly
提出日時 2016-08-11 16:48:25
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 817 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 12:11:19
合計ジャッジ時間 1,148 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%lld %lld", &a, &b);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  long long int a, b;
  int i;
  char a_str[15], b_str[15];
  scanf("%lld %lld", &a, &b);
  sprintf(a_str, "%lld", a);
  sprintf(b_str, "%lld", b);
  if(strlen(a_str) == strlen(b_str)){
    i = 0;
    while(a_str[i] != '\0'){
      if(a_str[i] == '4' && b_str[i] == '7'){
        printf("%s\n", a_str);
        return 0;
      }else if(a_str[i] == '7' && b_str[i] == '4'){
        printf("%s\n", b_str);
        return 0;
      }else if (a_str[i] != b_str[i]){
        break;
      }
      i++;
    }
  }
  if(a > b){
    printf("%lld\n",a);
  }else{
    printf("%lld\n",b);
  }
  return 0;
}
0