diff --git a/03-21/backend/flow.pdf b/03-21/backend/flow.pdf new file mode 100644 index 0000000..2ac1f63 Binary files /dev/null and b/03-21/backend/flow.pdf differ diff --git a/03-21/backend/main.c b/03-21/backend/main.c new file mode 100644 index 0000000..37c206a --- /dev/null +++ b/03-21/backend/main.c @@ -0,0 +1,27 @@ +#include +#include +#include + +int main() +{ + int nRand = 0, nGuess = 0, nCount = 0; + srand((unsigned)time(NULL)); + nRand = rand() % 1000 + 1; + printf("请输入1~1000的数字:"); + while (nGuess != nRand) + { + while (!scanf("%d", &nGuess)) + getchar(); // 防止用户输入非数字导致的死循环 + if (nGuess > nRand) + { + printf("大了!\n"); + } + else if (nGuess < nRand) + { + printf("小了!\n"); + } + nCount++; + } + printf("你猜中了!你猜了%d次!\n", nCount); + return 0; +} \ No newline at end of file diff --git a/03-21/backend/main.py b/03-21/backend/main.py new file mode 100644 index 0000000..b69ceff --- /dev/null +++ b/03-21/backend/main.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from random import random + +def main(): + rand_number = int(random() * 1000 + 1) + guess_number = 0 + count = 0 + + print('请输入1~1000的数字:') + while rand_number != guess_number: + guess_number = input() + if guess_number < rand_number: + print('小了') + elif guess_number > rand_number: + print('大了') + count += 1 + print('恭喜你!猜中了!你一共猜测了{}次'.format(count)) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/03-21/crawler/main.py b/03-21/crawler/main.py new file mode 100644 index 0000000..c9e3d77 --- /dev/null +++ b/03-21/crawler/main.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys +if sys.version_info.major == 3: + from urllib.request import urlopen # Python 3 +else: + from urllib2 import urlopen # Python 2 + + +rsp = urlopen('http://ip.sxisa.com/') +print(rsp.read()) \ No newline at end of file diff --git a/03-21/frontend/css/style.css b/03-21/frontend/css/style.css new file mode 100644 index 0000000..3a31c77 --- /dev/null +++ b/03-21/frontend/css/style.css @@ -0,0 +1,81 @@ +html { + min-height: 100%; + position: relative; +} +body { + max-width: 300px; + margin: auto; + font: 300 1em/1.8 PingFang SC,Lantinghei SC,Microsoft Yahei,Hiragino Sans GB,Microsoft Sans Serif,WenQuanYi Micro Hei,sans; + padding: 0 1em; +} + +.logo { + text-align: center; +} + +.logo img{ + width: 100%; + max-width: 300px; /*最大宽度不能大于图片宽度*/ +} + +:focus { + outline: none; +} + +.content .title{ + text-align: center; + font-size: 300%; + font-weight: 100; +} + +.input-text { + border: none; + width: 100%; + text-align: center; + font-size: 1.5em; + border-bottom: 1px dashed #000; + padding: .2em 0; +} + +.submit-btn { + -webkit-appearance: none; /* 取出ios系统按钮默认带有的渐变样式 */ + background-color: #AD190E; + color: #FFF; + border: 0; + width: 100%; + font-size: 1.5em; + padding: .5em; + border-radius: 1.25em; +} + +.submit-btn:hover { + cursor: pointer; +} + +.submit-btn:active { /*实现按下时按钮收缩效果*/ + padding: .45em; + margin: .05em; +} + +.tip { + text-align: center; +} + +.tip a { + color: #CCC; + text-decoration: none; +} + +footer { + text-align: center; + color: #CCC; + height: 4em; +} + +footer p { + font-size: 80%; + position: absolute; + bottom: 0; + width: 100%; + left: 0; +} \ No newline at end of file diff --git a/03-21/frontend/img/logo.png b/03-21/frontend/img/logo.png new file mode 100644 index 0000000..027bb52 Binary files /dev/null and b/03-21/frontend/img/logo.png differ diff --git a/03-21/frontend/index.html b/03-21/frontend/index.html new file mode 100644 index 0000000..a8a975a --- /dev/null +++ b/03-21/frontend/index.html @@ -0,0 +1,26 @@ + + + + + + + 报名查询 + + + +
+

+
+
+

报名查询

+
+

+

+
+

没查到报名?点击这里前往报名→

+
+ + + \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..37478fb --- /dev/null +++ b/readme.md @@ -0,0 +1,33 @@ +# 创软俱乐部项目训练 + +[后端] 3/21 猜数字 + +猜数字是已一个古老的游戏,由一个出题者随机出一个数字,由猜题者猜,若所猜数字大于所出数字,则出题者回答『大了』;若小于,则回答『小了』;直到猜题者猜中。现在请编写程序模拟出题者,随机数字在0~1000之间。当使用者猜中时,同时打印出猜测次数。 + +[爬虫] 3/21 获取IP + +访问网站:ip.sxisa.com 可以得到本机的外网IP。现在,请编写程序,打印出本机的外网IP。 + +[前端] 3/21 网站设计 + +按照设计图:https://coding.net/s/576fc1e8-5f9f-4863-8b5a-87adcc2e8e80 +制作出对应的网页。 + +--- + +[后端] 4/11 保存猜数字成绩 + +修改上一个程序,添加如下功能: +1. 当用户猜到数字之后,提示其输入一个昵称作为游戏名称,然后保存成绩,包含昵称,开始时间,耗时,所猜数字,猜测次数; +2. 游戏开启时,若用户已有设置了昵称,则输出提示语:你好!昵称~; +3. 然后提示选择 1. 玩猜数字;2. 查看历史成绩;3. 更改设置昵称; +4. 实现2,3功能。 + +[爬虫] 3/29 获取IP与IP相关信息 + +爬取 www.myip.cn 得到本机的外网IP,IP 地域,运营商。 + +[前端] 3/29 表单验证 + +修改上一个网页,添加如下功能: +当用户输入的电话号码非数字与长度不等于11位时,提示无效的手机号,同时禁用按钮,当输入符合要求时,则按钮恢复可用。 \ No newline at end of file