查看: 2044|回復: 2
打印 上一主題 下一主題

[公告]20140715更新

[複製鏈接]
  • TA的每日心情
    慵懶
    2015-4-10 14:18
  • 簽到天數: 78 天

    [LV.6]常住居民II

    176

    主題

    612

    帖子

    3959

    積分

    管理員

    Rank: 9Rank: 9Rank: 9

    積分
    3959

    台南一中資訊社新手達陣程式設計達人 - 2014

    跳轉到指定樓層
    樓主
    發表於 2014-7-15 20:54:51 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式

    趕快加入我們來參與討論吧!

    您需要 登錄 才可以下載或查看,沒有帳號?加入我們

    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>


    點評

    還有滑鼠去那按紐時 他會直接跑掉XD  發表於 2014-7-15 22:37
    "關注此帖" 是屬於要改的文字裡吧XD (簡字不說  發表於 2014-7-15 22:36
    回復

    使用道具 檢舉

    您需要登錄後才可以回帖 登入 | 加入我們

    本版積分規則

    快速回覆 返回頂部 返回列表