| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1284 人关注过本帖
标题:[求助]救救小妹吧。。不会做的 c语言题。。>o
取消只看楼主 加入收藏
nicole
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-8-29
收藏
 问题点数:0 回复次数:2 
[求助]救救小妹吧。。不会做的 c语言题。。>o
dogxbxxxnoon
bhellotherec
akciuqbrownm
xxxgexlahjij
xbzoxvuxxxox
xlxdzxexxxjx
xuxxblxnkgod

大家都有看过报章杂志上这类 word puzzle 的游戏。。(就找英文单字啊,打横打直,斜上或斜下的..)
小妹我的作业呢就是要用 c语言, 从以上的字母中找到

hello
dog
brown
join
row
quick
averyverylongword
noon
z
blue
blunt
help
even
blink

还要把那些字都自动用颜色 highlight 起来, 和显示结果,

The word "hello" was found 1 time in the grid.
The word "dog" was found 3 times in the grid.
The word "brown" was found 1 time in the grid.
The word "join" was found 1 time in the grid.
The word "row" was found 1 time in the grid.
The word "quick" was found 1 time in the grid.
The word "averyverylongword" was NOT found in the grid.
The word "noon" was found 2 times in the grid.
The word "z" was found 2 times in the grid.
The word "blue" was found 2 times in the grid.
The word "blunt" was NOT found in the grid.
The word "help" was NOT found in the grid.
The word "even" was found 1 time in the grid.
The word "blink" was NOT found in the grid.


过几天就要交了,但我还是完全不董要怎么做啊。。
那位哥哥或姐姐可以救救我啊。。!!?
拜托拉。。 >,<
我的e-mail, iam_nicole87@yahoo.com
搜索更多相关主题的帖子: c语言 小妹 
2006-08-29 15:36
nicole
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-8-29
收藏
得分:0 
我选读工程师了啦。。
谁知道有那么难得东西啊。。 ToT

我数学和科学都很好丫。。
就天生电脑白痴。。 >.<

各位哥哥一定要救救我丫。。


2006-08-29 19:19
nicole
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-8-29
收藏
得分:0 

终于从导员那儿求到提示了。。

但还是不明白。。@.@

希望各位高手哥哥可以看得明吧。。 拜托拉。。

-----------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>

/****************************************************************/
/* Constants and structure definitions */

/* Constant for the maximum size of all arrays */
#define MAXSIZE 50

/* Structure to hold information about the rectangular grid */
typedef struct
{
/* The letters in the grid */
char letters[MAXSIZE][MAXSIZE];
/* The number of rows in the grid */
int nRows;
/* The number of columns in the grid */
int nCols;
} GRID;

/* Structure to hold information about a search position */
typedef struct
{
/* The row number, starting from 0 */
int row;
/* The column number, starting from 0 */
int col;
} LOCATION;

/* Structure to hold information about the amount to move in a single
step of the searching process */
typedef struct
{
/* The amount to move in the row-direction: either -1, 0, or 1
depending on the direction of the search */
int deltaRow;
/* The amount to move in the column-direction: either -1, 0,
or 1 depending on the direction of the search */
int deltaColumn;
} MOVEMENT;

/* Enumeration for the possible search directions */
typedef enum {UP, DIAGUPRIGHT, RIGHT, DIAGDOWNRIGHT,
DOWN, DIAGDOWNLEFT, LEFT, DIAGUPLEFT} DIRECTION;

/****************************************************************/
/* Global variable definitions */
/* You should not need to add to this list */

/* A global variable for the rectangular grid of letters */
GRID grid;

/****************************************************************/
/* Functions */

/*
isValidGridEntry(c) returns true iff c is a valid character that can
appear in a grid-file.
*/
static bool isValidGridEntry(char c)
{
}

/*
isValidChar(c) returns true iff c is a valid character that can appear
in a words-file.
*/
static bool isValidChar(char c)
{
}

/*
trimLine(line) removes any trailing new-line or carriage-return
characters from the end of line.
*/
static void trimLine(char line[])
{
}

/*
readGrid(filename) reads the contents of the file named filename as a
grid-file, "filling" the grid global variable with information read
from the file. The function terminates the program if the file is
not a valid grid-file or if the corresponding grid would be too large
to store in the grid global variable.
*/
static void readGrid(char filename[])
{
}

/*
displayGrid(void) displays the rectangular grid of characters held
in the grid global variable.
*/
static void displayGrid(void)
{
}

/*
move(dir) returns a MOVEMENT structure that indicates how much to vary
an iteration through the rows and columns of the grid for a single
step of the searching process, when searching in a dir direction.
e.g. move(UP)={-1,0}; move(RIGHT)={0,1}; move(DIAGUPLEFT)={-1,-1}
*/
static MOVEMENT move(DIRECTION dir)
{
}

/*
isMatch(c, gridLetter) returns true iff c matches the (potentially
highlighted) gridLetter.
*/
static bool isMatch(char c, char gridLetter)
{
}

/*
searchForm(word, loc, dir) returns true iff word appears in the grid
starting at position loc in the dir direction.
*/
static bool searchFrom(char word[], LOCATION loc, DIRECTION dir)
{
}

/*
highlightLetter(c) returns the highlighted version of c.
*/
static char highlightLetter(char c)
{
}

/*
foundWord(word, loc, dir) highlights word in the grid. This function
assumes word has already been found in the grid starting at position
loc in the dir direction.
*/
static void foundWord(char word[], LOCATION loc, DIRECTION dir)
{
}

/*
search(word) returns the the number of times word appears in the grid.
*/
static int search(char word[])
{
}

/*
processWords(filename) reads the contents of the file named filename
as a words-file, searching for each word in turn in the grid. The
function terminates the program if the file is not a valid words-file.
The function also reports whether each word the file found in the
grid and the total number of words from the file found in the grid.
*/
static void processWords(char filename[])
{
}

/****************************************************************/
/* The main program */

int main(int argc, char *argv[])
{
/* Exit with an error if the the number of arguments (including
the name of the executable) is not 3 */
if(argc != 3)
{
fprintf(stderr, "Usage: %s grid-file words-file\n", argv[0]);
exit(EXIT_FAILURE);
}
else
{
/* Read the grid from file */
readGrid(argv[1]);
printf("Read grid from '%s'.", argv[1]);
printf(" The initial grid is:\n");
/* Display the contents of the grid */
displayGrid();

printf("\nProcessing words from file '%s'.\n", argv[2]);
/* Search for words, highlighting matches in the grid */
processWords(argv[2]);

printf("\nFinished task.");
printf(" The final grid is:\n");
/* Redisplay the contents of the grid */
displayGrid();

/* Finished successfully! */
exit(EXIT_SUCCESS);
}
return 0;
}
2006-08-31 12:00
快速回复:[求助]救救小妹吧。。不会做的 c语言题。。>o
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020226 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved