homework-04 抓瞎
程序截图
这是基本版本截图。。。。空都没填上
四个角的话 可以留下四个单词 最后添上就行
程序思路
在一个大平面上先一个中心,然后从中心向四周填词
每次填词时,寻找一个使得矩阵最小的
代目如下
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #define WORDLEN 12
- #define MID 15
- #define UP 0
- #define UP_R 1
- #define RIGHT 2
- #define DOWN_R 3
- #define DOWN 4
- #define DOWN_L 5
- #define LEFT 6
- #define UP_L 7
- int debug = ;
- char dictionary[][WORDLEN];
- char Word[][];
- int dictSign[]={};
- int dictSize;
- int a[];
- static void
- readDictionary(char *dictName)
- {
- FILE *h;
- char s[];
- int i;
- dictSize = ;
- h = fopen(dictName, "rt");
- fgets(s, , h);
- while (!feof(h)) {
- s[strlen(s)-] = '\0'; /* get rid of newline */
- strcpy(dictionary[dictSize++], s);
- fgets(s, , h);
- }
- printf("Dictionary size is %d\n", dictSize);
- for(i=; i<dictSize; i++){
- printf("%s\n",dictionary[i]);
- }
- }
- int getMax(){
- int max=,which=;
- int all=;
- for(int i=; i<dictSize; i++){
- if(dictSign[i] == )
- continue;
- int len = strlen(dictionary[i]);
- if(max < len){
- max = len;
- which = i;
- all = ;
- dictSign[i] = ;
- }
- }
- if(all == )
- return -;
- return which;
- }
- bool input(int x,int y,char *s,int direction){
- int len = strlen(s);
- switch(direction){
- case UP :
- for(int i=; i<len; i++){
- if(s[i] != Word[x-i][y] && Word[x-i][y] != )
- return false;
- }
- for(int i=; i<len; i++)
- Word[x-i][y]=s[i];
- break;
- case UP_R:
- for(int i=; i<len; i++){
- if(s[i] != Word[x-i][y+i] && Word[x-i][y+i] != )
- return false;
- }
- for(int i=; i<len; i++)
- Word[x-i][y+i]=s[i];
- break;
- case RIGHT:
- for(int i=; i<len; i++){
- if(s[i] != Word[x][y+i] && Word[x][y+i] != )
- return false;
- }
- for(int i=; i<len; i++)
- Word[x][y+i]=s[i];
- break;
- case DOWN_R:
- for(int i=; i<len; i++){
- if(s[i] != Word[x+i][y+i] && Word[x+i][y+i] != )
- return false;
- }
- for(int i=; i<len; i++)
- Word[x+i][y+i]=s[i];
- break;
- case DOWN:
- for(int i=; i<len; i++){
- if(s[i] != Word[x+i][y] && Word[x+i][y] != )
- return false;
- }
- for(int i=; i<len; i++)
- Word[x+i][y]=s[i];
- break;
- case DOWN_L:
- for(int i=; i<len; i++){
- if(s[i] != Word[x+i][y-i] && Word[x+i][y-i] != )
- return false;
- }
- for(int i=; i<len; i++)
- Word[x+i][y-i]=s[i];
- break;
- case LEFT:
- for(int i=; i<len; i++){
- if(s[i] != Word[x][y-i] && Word[x][y-i] != )
- return false;
- }
- for(int i=; i<len; i++)
- Word[x][y-i]=s[i];
- break;
- case UP_L:
- for(int i=; i<len; i++){
- if(s[i] != Word[x-i][y-i] && Word[x-i][y-i] != )
- return false;
- }
- for(int i=; i<len; i++)
- Word[x-i][y-i]=s[i];
- break;
- }
- return true;
- }
- void getWhere(int n){
- int layer;
- int n8=;
- for(int i=; ;i++){
- n8 += i*;
- if(n <= n8){
- layer = i;
- n8 -= i*;
- n = n-n8;
- int many = (n-)/(i*);
- switch(many){
- case :
- a[] = MID-i-+n;
- a[] = MID-i;
- break;
- case :
- a[] = MID-i+(n-)%(i*);
- a[] = MID+i;
- break;
- case :
- a[] = MID+i-(n-)%(i*);
- a[] = MID+i;
- break;
- case :
- a[] = MID+i-(n-)%(i*);
- a[] = MID-i;
- break;
- }
- break;
- }
- }
- }
- int getDirect(int x, int y){
- if(x>MID){
- if(y>MID)
- return DOWN_L;
- else if(y==MID)
- return LEFT;
- else
- return UP_L;
- }
- else if(x == MID){
- if(y > MID)
- return DOWN;
- else
- return UP;
- }
- else{
- if(y>MID)
- return DOWN_R;
- else if(y==MID)
- return RIGHT;
- else
- return UP_R;
- }
- }
- void ws_maker(){
- //printf("%d\n",getMax());
- char *s = dictionary[];
- input(MID,MID,s,DOWN);
- //printf("%s\n",s);
- for(int i=,j=; i<dictSize-;i++){
- int judge=;
- s = dictionary[i+];
- if(debug){
- printf("%d %s\n",i,s);
- }
- for(; ;j++){
- getWhere(j);
- int startD = (getDirect(a[],a[])+)%;
- for(int k=; k<=; k++){
- if(input(a[],a[],s,startD%)){
- judge = ;
- break;
- }
- }
- if(judge == )
- break;
- }
- }
- }
- int main(int argc, char **argv)
- {
- //printf("sb%s%d\n",*argv,argc);
- /* read in the dictionary */
- readDictionary(argv[]);
- ws_maker();
- //input(8,2,"love",UP);
- //input(8,1,"fove",UP_R);
- if(debug)
- for(int i=; i<; i++){
- for(int j=; j<; j++)
- printf("%C",Word[i][j]);
- printf("\n");
- }
- }
Personal Software Process Stages |
时间百分比(%) |
实际花费的时间 (分钟) |
原来估计的时间 (分钟) |
|
Planning |
计划 |
20 |
30 |
0 |
· Estimate |
· 估计这个任务需要多少时间,把工作细化并大致排序 |
20 |
30 |
0 |
Development |
开发 |
60 |
90 |
70 |
· Analysis |
· 需求分析 (包括学习新技术) |
10 |
15 |
0 |
· Design Spec |
· 生成设计文档 |
0 |
0 |
0 |
· Design Review |
· 设计复审 (和同事审核设计文档) |
0 |
0 |
0 |
· Coding Standard |
· 代码规范 (制定合适的规范) |
0 |
0 |
0 |
· Design |
· 具体设计 |
5 |
7.5 |
10 |
· Coding |
· 具体编码 |
20 |
30 |
45 |
· Code Review |
· 代码复审 |
5 |
7.5 |
10 |
· Test |
· 测试(自我测试,修改代码,提交修改) |
20 |
30 |
5 |
Reporting |
总结报告 |
20 |
30 |
30 |
· Test Report |
· 测试报告 |
10 |
15 |
10 |
· Size Measurement |
· 计算工作量 |
5 |
7.5 |
10 |
· Postmortem & Improvement Plan |
· 事后总结, 并提出改进 |
5 |
7.5 |
10 |
Total |
总计 |
100% |
总用时150 |
总估计的用时 100 |
homework-04 抓瞎的更多相关文章
- 现代程序设计homework——04
题目: 详见:http://www.cnblogs.com/xinz/p/3341551.html 题目本身确实很难,“很难想到一个比较优雅的算法”,这是一个老师请来专门讲解这道题的大牛的原话.确实, ...
- 小兔JS教程(四)-- 彻底攻略JS数组
在开始本章之前,先给出上一节的答案,参考答案地址: http://www.xiaotublog.com/demo.html?path=homework/03/index2 1.JS数组的三大特性 在J ...
- 小兔JS教程(五) 简单易懂的JSON入门
上一节的参考答案: http://xiaotublog.com/demo.html?path=homework/04/index2 本节重点来介绍一下JSON,JSON(JavaScript Obje ...
- hdu--1798--Doing Homework again(贪心)
Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Final阶段第1周/共1周 Scrum立会报告+燃尽图 04
作业要求[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2483] 版本控制:https://git.coding.net/liuyy08 ...
- 20181009-5 选题 Scrum立会报告+燃尽图 04
Scrum立会报告+燃尽图(04)选题 此作业要求参见:[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2194] 一.小组介绍 组长:刘 ...
- Beta阶段第2周/共2周 Scrum立会报告+燃尽图 04
此作业要求参见https://edu.cnblogs.com/campus/nenu/2018fall/homework/2412 版本控制地址 [https://git.coding.net/ ...
- 20181113-7 Beta阶段第1周/共2周 Scrum立会报告+燃尽图 04
作业要求:[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2386] 版本控制:[https://git.coding.net/lglr2 ...
- 20181016-4 Alpha阶段第1周/共2周 Scrum立会报告+燃尽图 04
此作业要求https://edu.cnblogs.com/campus/nenu/2018fall/homework/2248 Scrum master:徐常实 一.小组介绍 组长:王一可 组员:范靖 ...
- Python学习--04条件控制与循环结构
Python学习--04条件控制与循环结构 条件控制 在Python程序中,用if语句实现条件控制. 语法格式: if <条件判断1>: <执行1> elif <条件判断 ...
随机推荐
- ionic cordova file download and load
1.先添加插件 cordova plugin add org.apache.cordova.file cordova plugin add org.apache.cordova.file-transf ...
- Magento后台界面全局样式修改之——font-weight
路径: \app\design\adminhtml\Magento\backend\web\app\setup\styles\less\lib\_variables.less
- 字符串匹配KMP算法
1. 字符串匹配的KMP算法 2. KMP算法详解 3. 从头到尾彻底理解KMP
- 如何在某个按钮上触发 bootstarp Modal 组件
<?php Modal::begin([ 'id'=>'myModal', 'header' => '<h2>标题</h2>']); echo '内容'; M ...
- scribe日志分析工具安装
系统CentOS6.2 x86_64 1.yum安装gcc,flex,m4,python/python-devel,ruby,libevent/libevent-devel,openssl/opens ...
- Objective-C数据类型、数据类型转换
数据类型 1.Objective-C数据类型可以分为:基本数据类型.对象数据类型和id类型. 2.基本数据类型有:int.float.double和char类型. 3.对象类型就是类或协议所声明的指针 ...
- [leetcode]_Sum Root to Leaf Numbers
题目:计算一棵二叉树所有路径组成的数的总和. 思考:也是DFS的基础应用.虽然还是套着别人的DFS框架写的,但是学习通常会经历先模拟,再创新的过程. 代码: private int sum = 0; ...
- Operation is not valid due to the current state of the object.
今天遇到一个asp.net的草郁闷的问题,看下截图 狂晕啊,在google上狂搜了一下,好在已经有大侠也遇到过这个问题了,先看下别人的解决办法吧 Operation is not valid due ...
- Hive中典型的表内数据除重写法
insert overwrite table store select t.p_key,t.sort_word from ( select p_key, sort_word , row_number( ...
- JSP标记
JSP标记是JSP页面中很重要的组成部分,JSP标记包括指令标记.动作标记和自定义标记.其中自定义标记主要讲述与Tag文件有关的Tag标记. 一 指令标记page Page指令标记,简称page指令, ...