結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー Himatsubushin
提出日時 2022-03-02 13:44:10
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 1,269 ms
コンパイル使用メモリ 28,928 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-16 06:53:27
合計ジャッジ時間 1,892 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool check1(char *);
bool check2(char *);

int main(void) {
  char in1[6], in2[6];
  
  scanf("%s", in1);
  scanf("%s", in2);

  if (!check1(in1)) return EXIT_SUCCESS;
  if (!check1(in2)) return EXIT_SUCCESS;
  if (!check2(in1)) return EXIT_SUCCESS;
  if (!check2(in2)) return EXIT_SUCCESS;

  printf("OK");
  
  return EXIT_SUCCESS;
}

bool check1(char *s) {
  int num;
  
  sscanf(s, "%d", &num);

  if (num > 12345) {
    printf("NG");
    return false;
  }

  return true;
}

bool check2(char *s) {
  if (*s == '0' && strlen(s) > 1) {
    printf("NG");
    return false;
  }

  while (*s != '\0') {
    if (*s < '0' || *s > '9') {
      printf("NG");
      return false;
    }
    s++;
  }

  return  true;
}
0