結果

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

ソースコード

diff #

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

char *comp(char *a, char *b, int alen, int blen) {
	int i;
	if (alen != blen) return alen > blen ? a : b;
	else {
		for (i = 0; i < alen; i++) {
			if (a[i] == b[i]) continue;
			else if (a[i] == '4' && b[i] == '7') return a;
			else if (a[i] == '7' && b[i] == '4') return b;
			else return a[i] > b[i] ? a : b;
		}
	}
}

int main() {
	char a[11], b[11];

	scanf("%s %s", a, b);
	printf("%s\n", comp(a, b, strlen(a), strlen(b)));
	
	return 0;
}
0