趕快加入我們來參與討論吧!
您需要 登錄 才可以下載或查看,沒有帳號?加入我們
x
1.新增「關注帖子」功能,在文章標題旁邊,讓你可以收到回文訊息。
2.更新「代碼」,舊有的code標籤仍可使用,新版的支援多種程式碼之套色,以及顯示行號之功能,歡迎使用
C++ Demo
[C++] 純文本查看 復制代碼 #include<cstdio>
using namespace std;
int main()
{
char s[100];
gets(s);
printf("Hello ,%s !\n",s);
return 0;
}
PHP Demo
[PHP] 純文本查看 復制代碼 <?php
$uid=6;
$problist=array(36,37,39,53,66,67,68);
function Post($url, $post = null){
$context = array();
if (is_array($post)) {
ksort($post);
$context['http'] = array (
'timeout' => 60,
'method' => 'POST',
'content' => http_build_query($post, '', '&'),
);
}
return file_get_contents($url, false, stream_context_create($context));
}
function getTOJNonSolveState($uid,$problist)
{
if(!is_array($problist)||!is_string($uid))
{
return false;
}
$data = array(
'reqtype' => 'AC',
'acct_id' => $uid
);
$json = Post('http://210.70.137.215/oj/be/api', $data);
$UserAcceptList = json_decode($json)->{"ac"};
$nonSolve=array();
//var_dump($UserAcceptList);
foreach ( $problist as $i)
{
$flag=0;
foreach ( $UserAcceptList as $j)
{
if( $i == $j )
$flag=1;
}
if($flag == 0)
array_push($nonSolve,$i);
}
return $nonSolve;
}
function ask($uid,$problist)
{
$rev=getTOJNonSolveState($uid,$problist);
if(!is_array($rev))
{
echo "Something wrong...";
exit;
}
$num = count($rev);
if($num==0)
{
echo "Well done!";
}
else
{
echo "Leave $num problem:";
foreach($rev as $i)
{
echo "$i,";
}
}
}
?>
<!DOCTYPE HTML>
<title> test </title>
<head>
<title>TOJ test</title>
<meta charset="UTF8">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<style type="text/css">
tr:nth-of-type(even) {
background-color: #f3f3f3;
}
tr:nth-of-type(odd) {
background-color: #ddd;
}
</style>
</head>
<body>
<h1>TOJ 簡單題查詢</h1>
<form action='test.php' method='POST' style='width:256px; margin:128px 128px;'>
<input type='text' name='uid' class='form-control' placeholder='請輸入TOJ UID'><br>
<input type='submit' value='Submit' class='btn btn-primary'>
</form>
<?php
if(isset($_POST["uid"]))
{
$rule = "/^[0-9]{1,}$/";
$uid=$_POST['uid'];
if(!preg_match($rule,$uid))
{
echo "<h2>不正確的UID</h2>";
}
else
{
echo "<h2>User $uid:</h2>";
?><h3><?php
ask($_POST["uid"],$problist);
?></h3><?php
}
}
?>
</body>
|