程序截图

这是基本版本截图。。。。空都没填上

四个角的话 可以留下四个单词 最后添上就行

程序思路

在一个大平面上先一个中心,然后从中心向四周填词

每次填词时,寻找一个使得矩阵最小的

代目如下

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. #define WORDLEN 12
  6. #define MID 15
  7. #define UP 0
  8. #define UP_R 1
  9. #define RIGHT 2
  10. #define DOWN_R 3
  11. #define DOWN 4
  12. #define DOWN_L 5
  13. #define LEFT 6
  14. #define UP_L 7
  15.  
  16. int debug = ;
  17. char dictionary[][WORDLEN];
  18. char Word[][];
  19. int dictSign[]={};
  20. int dictSize;
  21. int a[];
  22.  
  23. static void
  24. readDictionary(char *dictName)
  25. {
  26. FILE *h;
  27. char s[];
  28. int i;
  29.  
  30. dictSize = ;
  31. h = fopen(dictName, "rt");
  32. fgets(s, , h);
  33. while (!feof(h)) {
  34. s[strlen(s)-] = '\0'; /* get rid of newline */
  35. strcpy(dictionary[dictSize++], s);
  36. fgets(s, , h);
  37. }
  38. printf("Dictionary size is %d\n", dictSize);
  39.  
  40. for(i=; i<dictSize; i++){
  41. printf("%s\n",dictionary[i]);
  42. }
  43. }
  44.  
  45. int getMax(){
  46. int max=,which=;
  47. int all=;
  48. for(int i=; i<dictSize; i++){
  49. if(dictSign[i] == )
  50. continue;
  51. int len = strlen(dictionary[i]);
  52. if(max < len){
  53. max = len;
  54. which = i;
  55. all = ;
  56. dictSign[i] = ;
  57. }
  58. }
  59. if(all == )
  60. return -;
  61. return which;
  62. }
  63.  
  64. bool input(int x,int y,char *s,int direction){
  65. int len = strlen(s);
  66.  
  67. switch(direction){
  68. case UP :
  69. for(int i=; i<len; i++){
  70. if(s[i] != Word[x-i][y] && Word[x-i][y] != )
  71. return false;
  72. }
  73. for(int i=; i<len; i++)
  74. Word[x-i][y]=s[i];
  75. break;
  76. case UP_R:
  77. for(int i=; i<len; i++){
  78. if(s[i] != Word[x-i][y+i] && Word[x-i][y+i] != )
  79. return false;
  80. }
  81. for(int i=; i<len; i++)
  82. Word[x-i][y+i]=s[i];
  83. break;
  84. case RIGHT:
  85. for(int i=; i<len; i++){
  86. if(s[i] != Word[x][y+i] && Word[x][y+i] != )
  87. return false;
  88. }
  89. for(int i=; i<len; i++)
  90. Word[x][y+i]=s[i];
  91. break;
  92. case DOWN_R:
  93. for(int i=; i<len; i++){
  94. if(s[i] != Word[x+i][y+i] && Word[x+i][y+i] != )
  95. return false;
  96. }
  97. for(int i=; i<len; i++)
  98. Word[x+i][y+i]=s[i];
  99. break;
  100. case DOWN:
  101. for(int i=; i<len; i++){
  102. if(s[i] != Word[x+i][y] && Word[x+i][y] != )
  103. return false;
  104. }
  105. for(int i=; i<len; i++)
  106. Word[x+i][y]=s[i];
  107. break;
  108. case DOWN_L:
  109. for(int i=; i<len; i++){
  110. if(s[i] != Word[x+i][y-i] && Word[x+i][y-i] != )
  111. return false;
  112. }
  113. for(int i=; i<len; i++)
  114. Word[x+i][y-i]=s[i];
  115. break;
  116. case LEFT:
  117. for(int i=; i<len; i++){
  118. if(s[i] != Word[x][y-i] && Word[x][y-i] != )
  119. return false;
  120. }
  121. for(int i=; i<len; i++)
  122. Word[x][y-i]=s[i];
  123. break;
  124. case UP_L:
  125. for(int i=; i<len; i++){
  126. if(s[i] != Word[x-i][y-i] && Word[x-i][y-i] != )
  127. return false;
  128. }
  129. for(int i=; i<len; i++)
  130. Word[x-i][y-i]=s[i];
  131. break;
  132. }
  133. return true;
  134. }
  135.  
  136. void getWhere(int n){
  137. int layer;
  138. int n8=;
  139. for(int i=; ;i++){
  140. n8 += i*;
  141. if(n <= n8){
  142. layer = i;
  143. n8 -= i*;
  144. n = n-n8;
  145. int many = (n-)/(i*);
  146.  
  147. switch(many){
  148. case :
  149. a[] = MID-i-+n;
  150. a[] = MID-i;
  151. break;
  152. case :
  153. a[] = MID-i+(n-)%(i*);
  154. a[] = MID+i;
  155. break;
  156. case :
  157. a[] = MID+i-(n-)%(i*);
  158. a[] = MID+i;
  159. break;
  160. case :
  161. a[] = MID+i-(n-)%(i*);
  162. a[] = MID-i;
  163. break;
  164. }
  165. break;
  166. }
  167. }
  168. }
  169. int getDirect(int x, int y){
  170. if(x>MID){
  171. if(y>MID)
  172. return DOWN_L;
  173. else if(y==MID)
  174. return LEFT;
  175. else
  176. return UP_L;
  177. }
  178. else if(x == MID){
  179. if(y > MID)
  180. return DOWN;
  181. else
  182. return UP;
  183. }
  184. else{
  185. if(y>MID)
  186. return DOWN_R;
  187. else if(y==MID)
  188. return RIGHT;
  189. else
  190. return UP_R;
  191. }
  192. }
  193.  
  194. void ws_maker(){
  195. //printf("%d\n",getMax());
  196. char *s = dictionary[];
  197. input(MID,MID,s,DOWN);
  198. //printf("%s\n",s);
  199.  
  200. for(int i=,j=; i<dictSize-;i++){
  201. int judge=;
  202. s = dictionary[i+];
  203.  
  204. if(debug){
  205. printf("%d %s\n",i,s);
  206. }
  207. for(; ;j++){
  208. getWhere(j);
  209. int startD = (getDirect(a[],a[])+)%;
  210. for(int k=; k<=; k++){
  211. if(input(a[],a[],s,startD%)){
  212. judge = ;
  213. break;
  214. }
  215. }
  216. if(judge == )
  217. break;
  218. }
  219. }
  220. }
  221.  
  222. int main(int argc, char **argv)
  223. {
  224. //printf("sb%s%d\n",*argv,argc);
  225. /* read in the dictionary */
  226. readDictionary(argv[]);
  227. ws_maker();
  228. //input(8,2,"love",UP);
  229. //input(8,1,"fove",UP_R);
  230. if(debug)
  231. for(int i=; i<; i++){
  232. for(int j=; j<; j++)
  233. printf("%C",Word[i][j]);
  234. printf("\n");
  235. }
  236.  
  237. }

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 抓瞎的更多相关文章

  1. 现代程序设计homework——04

    题目: 详见:http://www.cnblogs.com/xinz/p/3341551.html 题目本身确实很难,“很难想到一个比较优雅的算法”,这是一个老师请来专门讲解这道题的大牛的原话.确实, ...

  2. 小兔JS教程(四)-- 彻底攻略JS数组

    在开始本章之前,先给出上一节的答案,参考答案地址: http://www.xiaotublog.com/demo.html?path=homework/03/index2 1.JS数组的三大特性 在J ...

  3. 小兔JS教程(五) 简单易懂的JSON入门

    上一节的参考答案: http://xiaotublog.com/demo.html?path=homework/04/index2 本节重点来介绍一下JSON,JSON(JavaScript Obje ...

  4. hdu--1798--Doing Homework again(贪心)

    Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  5. Final阶段第1周/共1周 Scrum立会报告+燃尽图 04

    作业要求[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2483] 版本控制:https://git.coding.net/liuyy08 ...

  6. 20181009-5 选题 Scrum立会报告+燃尽图 04

    Scrum立会报告+燃尽图(04)选题 此作业要求参见:[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2194] 一.小组介绍 组长:刘 ...

  7. Beta阶段第2周/共2周 Scrum立会报告+燃尽图 04

    此作业要求参见https://edu.cnblogs.com/campus/nenu/2018fall/homework/2412 版本控制地址    [https://git.coding.net/ ...

  8. 20181113-7 Beta阶段第1周/共2周 Scrum立会报告+燃尽图 04

    作业要求:[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2386] 版本控制:[https://git.coding.net/lglr2 ...

  9. 20181016-4 Alpha阶段第1周/共2周 Scrum立会报告+燃尽图 04

    此作业要求https://edu.cnblogs.com/campus/nenu/2018fall/homework/2248 Scrum master:徐常实 一.小组介绍 组长:王一可 组员:范靖 ...

  10. Python学习--04条件控制与循环结构

    Python学习--04条件控制与循环结构 条件控制 在Python程序中,用if语句实现条件控制. 语法格式: if <条件判断1>: <执行1> elif <条件判断 ...

随机推荐

  1. ionic icons and splash

    ionic 用cordova  可以直接设置自己的icons ,不用修改默认的图片了 1.在自己的根目录下新建一个文件夹 如icons 2.然后在icons文件夹下再建一个iOS 文件夹存放所需要的图 ...

  2. 纯CSS气泡框实现方法探究

    气泡框(或者提示框)是网页中一种很常见的元素,大多用来展示提示信息,如下图所示: 拆分来看,形如这种气泡框无外乎就是一个矩形框+一个指示方向的三角形小箭头,要制作出这样的气泡框,如果解决了三角形小箭头 ...

  3. 【C#基础】static 关键字用法小结

    静态变量 当我们编写一个类时,其实就是在描述其对象的属性和行为,而并没有产生实质上的对象,只有通过new关键字才会产生出对象,这时系统才会分配内存空间给对象,其方法才可以供外部调用. 有时候,我们希望 ...

  4. hadoop 根据SecondaryNameNode恢复Namenode

    1.修改conf/core-site.xml 增加 <property> <name>fs.checkpoint.period</name> <value&g ...

  5. .NET中 使用数组的注意事项

    1.初始值问题 对于int.double.float等一些值类型数组,没有赋值的情况下, 默认值是0: 而对于String 等引用类型,初始值为null. 2.IndexOutOfRangeExcep ...

  6. 实例分析ELF文件动态链接

    参考文献: <ELF V1.2> <程序员的自我修养---链接.装载与库>第6章 可执行文件的装载与进程 第7章 动态链接 <Linux GOT与PLT> 开发平台 ...

  7. 字符串匹配KMP算法

    1. 字符串匹配的KMP算法 2. KMP算法详解 3. 从头到尾彻底理解KMP

  8. Dynamic view

    Views are a useful feature of SQL databases, letting us create virtual tables based on SQL select st ...

  9. 将List<T>转化成 DataTable--调整可空类型的转化错误

    加载表结构并保持成XML string cmdText = @"select * from kb_lable_temp where 1=2"; using (SqlConnecti ...

  10. yhd日志分析(二)

    yhd日志分析(二) 继续yhd日志分析,统计数据 日期 uv pv 登录人数 游客人数 平均访问时长 二跳率 独立ip数 1 分析 登录人数 count(distinct endUserId) 游客 ...