結果

問題 No.138 化石のバージョン
ユーザー seaside0002
提出日時 2020-01-12 12:36:31
言語 PHP
(843.2)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 30,928 KB
実行使用メモリ 31,708 KB
最終ジャッジ日時 2024-11-28 16:20:28
合計ジャッジ時間 3,848 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$fossilVer = trim(fgets(STDIN));
$target = trim(fgets(STDIN));

$X = new something($target);

$X->comparVer($fossilVer, $target);

if($X->status == 'OLD'){
	echo 'YES';
}else if($X->status == 'NEW'){
	echo 'NO';
}


class something{
	public $version;
	public $status;
	
	function __construct($target){
		$this->version = $target;
	}
	
	function comparVer($fossil, $tar){
		$fos = explode('.', $fossil);
		$t = explode('.', $tar);
		
		if(!(count($fos) == count($t))){
			die("ERROR!");
		}else{
			$roop = count($fos);
		}
		
		for($i = 0; $i < $roop; $i++){
			if($fos[$i] >= $t[$i]){
				continue;
			}else{
				$this->status = 'NEW';
				return;
			}
		}
		
		$this->status = 'OLD';
	}
}
0