結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー tj_0612tj_0612
提出日時 2016-11-18 22:51:06
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 21,888 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-26 07:32:45
合計ジャッジ時間 710 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s",A);
      |         ^~~~~~~~~~~~~
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%s",B);
      |         ^~~~~~~~~~~~~

ソースコード

diff #

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

int main(){
	char A[5],B[5];
	scanf("%s",A);
	scanf("%s",B);
	
	int a,b,aflag,bflag;
	int alen,blen;
	alen = strlen(A);
	blen = strlen(B);
	int i;
	for(i=0;i<alen;i++){
		a=A[i]-'0';
		if(a<0||a>9){
			printf("NG\n");
			return 0;
			break;
		}
		if(i!=0){
			if(a!=0){
				if(aflag==0){
					printf("NG\n");
					return 0;
					break;
				}
				aflag=1;
				
			}
			else if(aflag==0){
				printf("NG\n");
				return 0;
				break;
			}
		} else if(a!=0) aflag=1;
	}
		for(i=0;i<blen;i++){
		b=B[i]-'0';
		if(b<0||b>9){
			printf("NG\n");
			return 0;
			break;
		}
		if(i!=0){
			if(b!=0){
				if(bflag==0){
					printf("NG\n");
					return 0;
					break;
				}
				bflag=1;
			}
			else if(bflag==0){
				printf("NG\n");
				return 0;
				break;
			}
		}else if(b!=0) bflag=1;
	}
	a = atoi(A);
	b = atoi(B);
	if(a>12345||b>12345){
		printf("NG\n");
		return 0;
	}
	printf("OK\n");

	return 0;
}
0