本文整理汇总了PHP中solve函数的典型用法代码示例。如果您正苦于以下问题:PHP solve函数的具体用法?PHP solve怎么用?PHP solve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了solve函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculatePoints
function calculatePoints($formula, $data)
{
var_dump($formula);
var_dump($data);
$formula = str_replace('=', '', $formula);
if (count($data) == 0) {
$data['valor_informado'] = 0;
$data['classif_informado'] = 0;
}
if (isset($data['valor_informado'])) {
$formula = str_replace('valor_informado', $data['valor_informado'], $formula);
}
if (isset($data['classif_informado'])) {
$formula = str_replace('classif_informado', $data['classif_informado'], $formula);
}
if (isset($data['decorrente_informado'])) {
if (count($data['decorrente_informado']) == 1) {
$formula = str_replace('decorrente_informado', $data['decorrente_informado'][0], $formula);
} else {
if (count($data['decorrente_informado']) == 2) {
$formula = str_replace('decorrente_informado_1', $data['decorrente_informado'][0], $formula);
$formula = str_replace('decorrente_informado_2', $data['decorrente_informado'][1], $formula);
}
}
} else {
$formula = str_replace('decorrente_informado_1', '0', $formula);
$formula = str_replace('decorrente_informado_2', '0', $formula);
$formula = str_replace('decorrente_informado', '0', $formula);
}
var_dump($formula);
return solve($formula);
return -1;
}
示例2: main
function main()
{
global $argv, $argc, $TEST;
// for testing purposes
if ($argc == 2 and $argv[1] == "test") {
$stream = fopen('php://memory', 'r+');
fwrite($stream, $TEST);
rewind($stream);
solve($stream);
return;
}
solve(STDIN);
}
示例3: solve
function solve($wire)
{
global $wires;
if (is_numeric($wire)) {
return (int) $wire;
} else {
if (is_numeric($wires[$wire])) {
return (int) $wires[$wire];
} else {
switch ($wires[$wire]['op']) {
case 'SET':
$value = solve($wires[$wire]['ref']);
break;
case 'NOT':
$value = ~solve($wires[$wire]['ref']) & 65535;
break;
case 'AND':
$value = solve($wires[$wire]['ref'][0]) & solve($wires[$wire]['ref'][1]);
break;
case 'OR':
$value = solve($wires[$wire]['ref'][0]) | solve($wires[$wire]['ref'][1]);
break;
case 'XOR':
$value = solve($wires[$wire]['ref'][0]) ^ solve($wires[$wire]['ref'][1]);
break;
case 'RSHIFT':
$value = solve($wires[$wire]['ref'][0]) >> solve($wires[$wire]['ref'][1]);
break;
case 'LSHIFT':
$value = solve($wires[$wire]['ref'][0]) << solve($wires[$wire]['ref'][1]);
break;
}
$wires[$wire] = $value;
return $value;
}
}
}
示例4: solve
<?php
function solve($string)
{
list($letters, $numbers) = explode("|", $string);
foreach (explode(" ", $numbers) as $number) {
echo $letters[$number - 1];
}
echo "\n";
}
foreach (file($argv[1]) as $line) {
if (trim($line) != "") {
solve(trim($line));
}
}
示例5: foreach
case 'OR':
$solved[$var] = $values[0] | $values[1];
break;
case 'NOT':
$solved[$var] = ~$values[0];
break;
case '->':
$solved[$var] = $values[0];
break;
}
// substitute obtained value
foreach ($eqs as $var2 => $eq2) {
if (isset($solved[$var2])) {
continue;
}
for ($j = 0; $j < count($eqs[$var2]['values']); $j++) {
if ($eqs[$var2]['values'][$j] === $var) {
$eqs[$var2]['values'][$j] = $solved[$var];
}
}
}
}
}
}
return $solved;
}
$vars = solve($eqs);
printf('ans#7.1: %u' . PHP_EOL, $vars['a']);
$eqs['b']['values'] = [$vars['a']];
$vars = solve($eqs);
printf('ans#7.2: %u' . PHP_EOL, $vars['a']);
示例6: login_chk
<?php
include "./config.php";
login_chk();
dbconnect();
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[no])) {
exit("No Hack ~_~");
}
if (preg_match('/\'/i', $_GET[pw])) {
exit("HeHe");
}
if (preg_match('/\'|substr|ascii|=|or|and| |like|0x/i', $_GET[no])) {
exit("HeHe");
}
$query = "select id from prob_bugbear where id='guest' and pw='{$_GET[pw]}' and no={$_GET[no]}";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
echo "<h2>Hello {$result[id]}</h2>";
}
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_bugbear where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['pw'] && $result['pw'] == $_GET['pw']) {
solve("bugbear");
}
highlight_file(__FILE__);
示例7: login_chk
<?php
include "./config.php";
login_chk();
dbconnect();
if (preg_match('/\'/i', $_GET[pw])) {
exit("No Hack ~_~");
}
$query = "select id from prob_assassin where pw like '{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
echo "<h2>Hello {$result[id]}</h2>";
}
if ($result['id'] == 'admin') {
solve("assassin");
}
highlight_file(__FILE__);
示例8: solve
function solve($aPoss, $nTotal, $aNo)
{
$aRes = [];
//Last Cell
if (count($aPoss) == 1) {
if ($nTotal < 10 && !in_array($nTotal, $aNo)) {
$p = array_search($nTotal, $aPoss[0]);
if ($p !== false) {
$aRes[] = str_repeat(' ', $p) . $nTotal . str_repeat(' ', count($aPoss[0]) - $p);
}
}
return $aRes;
}
$aPossB = $aPoss;
$aMyPoss = array_shift($aPossB);
$nMyCnt = count($aMyPoss);
foreach ($aMyPoss as $i => $n) {
if ($n >= $nTotal || in_array($n, $aNo)) {
continue;
}
$aMyNo = $aNo;
$aMyNo[] = $n;
$str = str_repeat(' ', $i) . $n . str_repeat(' ', $nMyCnt - $i);
$aNewPoss = solve($aPossB, $nTotal - $n, $aMyNo);
foreach ($aNewPoss as $cP) {
$aRes[] = $str . $cP;
}
}
return $aRes;
}
示例9: fopen
<?php
$inputFile = $_SERVER['argv'][1];
$outputFile = $inputFile . '.out';
$fin = fopen($inputFile, 'r');
$fout = fopen($outputFile, 'w+');
$cases = fgets($fin);
$case = 0;
while (!feof($fin)) {
$case++;
$in = fgets($fin);
if ($case > $cases) {
break;
}
list($combs, $opps, $inv) = parse($in);
$out = solve($combs, $opps, $inv);
$res = sprintf("Case #%d: %s\n", $case, format($out));
fputs($fout, $res);
echo "{$res}";
}
function parse($in)
{
$in = explode(' ', $in);
$numComb = (int) $in[0];
$combs = array_slice($in, 1, $numComb);
$in = array_slice($in, $numComb + 1);
$numOpp = (int) $in[0];
$opps = array_slice($in, 1, $numOpp);
$in = array_slice($in, $numOpp + 1);
$numInv = (int) $in[0];
$inv = array();
示例10: next_step
function next_step($new_position, $val, $status)
{
$answer = array();
if ($status[$new_position] == 1) {
// new_positionはすでに踏んでるので調査終了
//$answer[][0] = 999;
} else {
$status[$new_position] = 1;
if (!in_array(0, $status)) {
// new_positionでゴール
$answer[][0] = $new_position;
}
// new_positionではゴールも終了もしないで調査続行
$answer = array_merge($answer, solve($new_position, $val, $status));
}
return $answer;
}
示例11: login_chk
<?php
include "./config.php";
login_chk();
dbconnect();
if (strlen($_GET[shit]) > 1) {
exit("No Hack ~_~");
}
if (preg_match('/ |\\n|\\r|\\t/i', $_GET[shit])) {
exit("HeHe");
}
$query = "select 1234 from{$_GET[shit]}prob_giant where 1";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result[1234]) {
solve("giant");
}
highlight_file(__FILE__);
示例12: login_chk
<?php
include "./config.php";
login_chk();
dbconnect();
if (preg_match('/_|\\.|\\(\\)/i', $_GET[limit])) {
exit("No Hack ~_~");
}
if (preg_match('/union|where|hellfire/i', $_GET[limit])) {
exit("hehe");
}
if ($_GET[limit]) {
$limit = $_GET[limit];
} else {
$limit = 1;
}
$query = "select id from probevilwizard where id='admin' limit {$limit}";
$result = @mysql_fetch_array(mysql_query($query));
if (mysql_error()) {
exit;
}
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from probevilwizard where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['pw'] && $result['pw'] == $_GET['pw']) {
solve("evil_wizard");
}
highlight_file(__FILE__);
示例13: login_chk
<?php
include "./config.php";
login_chk();
dbconnect();
if (preg_match('/_|\\.|\\(\\)/i', $_GET[limit])) {
exit("No Hack ~_~");
}
if (preg_match('/union|where|evilwizard/i', $_GET[limit])) {
exit("hehe");
}
if ($_GET[limit]) {
$limit = $_GET[limit];
} else {
$limit = 1;
}
$query = "select id from probhellfire where id='admin' limit {$limit}";
$result = @mysql_fetch_array(mysql_query($query));
if (mysql_error()) {
exit(mysql_error());
}
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from probhellfire where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['pw'] && $result['pw'] == $_GET['pw']) {
solve("hell_fire");
}
highlight_file(__FILE__);
示例14: login_chk
<?php
include "./config.php";
login_chk();
dbconnect();
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[no])) {
exit("No Hack ~_~");
}
if (preg_match('/\'|\\"|\\`/i', $_GET[no])) {
exit("No Quotes ~_~");
}
$query = "select id from prob_goblin where id='guest' and no={$_GET[no]}";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
echo "<h2>Hello {$result[id]}</h2>";
}
if ($result['id'] == 'admin') {
solve("goblin");
}
highlight_file(__FILE__);
示例15: login_chk
<?php
include "./config.php";
login_chk();
dbconnect();
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[id])) {
exit("No Hack ~_~");
}
// do not try to attack another table, database!
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[pw])) {
exit("No Hack ~_~");
}
$query = "select id from prob_gremlin where id='{$_GET[id]}' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
solve("gremlin");
}
highlight_file(__FILE__);