哈佛大学公开课cs50
http://download.csdn.net/detail/cheng5129540/3763638#comment这里有问题集,建议从这里下载,但是没有源码,所以找了源码。
这里面3,4,5有2种版本,5,7,8只有普通的,而1,2的问题集是没源码的。
所有都可以从这下载的:http://cs50.tv/2010/fall/#l=psets&r=about&v=lectures/0/week0w
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2916 2011-02-12 14:21 pset4debug.bin
文件 331776 2011-02-12 14:21 pset4l33t.bin
文件 239 2011-09-30 06:33 pset4Makefile
文件 331776 2011-02-12 14:21 pset4
00b.bin
文件 12537 2011-02-12 14:21 pset4sudoku.c
文件 751 2011-02-12 14:21 pset4sudoku.h
文件 2013 2010-10-15 18:31 pset5mpmp.h
文件 921656 2010-10-15 18:22 pset5mpclue.bmp
文件 2595 2010-10-15 18:21 pset5mpcopy.c
文件 486 2010-10-15 18:21 pset5mplarge.bmp
文件 429 2010-10-15 18:23 pset5mpMakefile
文件 90 2010-10-15 18:21 pset5mpsmall.bmp
文件 246 2010-10-15 18:21 pset5mpsmiley.bmp
文件 0 2010-10-15 18:32 pset5questions.txt
文件 852 2010-10-23 10:31 pset6dictionary.c
文件 871 2010-10-23 10:31 pset6dictionary.h
文件 662 2010-10-23 10:31 pset6Makefile
文件 0 2010-10-23 10:31 pset6questions.txt
文件 5141 2010-10-23 10:31 pset6speller.c
文件 167529 2010-09-11 13:15 pset6 extsalice.txt
文件 704132 2010-09-11 13:15 pset6 extsausten.txt
文件 159309 2010-09-11 13:15 pset6 extsaustinpowers.txt
文件 182029 2010-09-11 13:15 pset6 extschristmas.txt
文件 45118 2010-09-11 13:15 pset6 extsconstitution.txt
文件 875 2010-09-11 13:15 pset6 extsdaffodils.txt
文件 874627 2010-09-11 13:15 pset6 extsdracula.txt
文件 1205891 2010-09-11 13:15 pset6 extsfederalist.txt
文件 463156 2010-09-11 13:15 pset6 extsfrankenstein.txt
文件 532695 2010-09-11 13:15 pset6 extsgrimm.txt
文件 6617503 2010-09-11 13:15 pset6 extsholmes.txt
............此处省略177个文件信息
/***************************************************************************
* fifteen.c
*
* Computer Science 50
* Problem Set 3
*
* Implements The Game of Fifteen (generalized to d x d).
*
* Usage: fifteen d
*
* whereby the board‘s dimensions are to be d x d
* where d must be in [DIM_MINDIM_MAX]
*
* Note that usleep is obsolete but it offers more granularity than
* sleep and is simpler to use than nanosleep; ‘man usleep‘ for more.
***************************************************************************/
#define _XOPEN_SOURCE 500
#include
#include
#include
#include
// constants
#define DIM_MIN 3
#define DIM_MAX 9
// board
int board[DIM_MAX][DIM_MAX];
// dimensions
int d;
// prototypes
void clear(void);
void greet(void);
void init(void);
void draw(void);
bool move(int tile);
bool won(void);
int
main(int argc char *argv[])
{
// greet user with instructions
greet();
// ensure proper usage
if (argc != 2)
{
printf(“Usage: %s d
“ argv[0]);
return 1;
}
// ensure valid dimensions
d = atoi(argv[1]);
if (d < DIM_MIN || d > DIM_MAX)
{
printf(“Board must be between %d x %d and %d x %d inclusive.
“
DIM_MIN DIM_MIN DIM_MAX DIM_MAX);
return 2;
}
// initialize the board
init();
// accept moves until game is won
while (true)
{
// clear the screen
clear();
// draw the current state of the board
draw();
// check for win
if (won())
{
printf(“ftw!
“);
break;
}
// prompt for move
printf(“Tile to move: “);
int tile = GetInt();
// move if possible else report illegality
if (!move(tile))
{
printf(“
Illegal move.
“);
usleep(500000);
}
// sleep thread for animation‘s sake
usleep(500000);
}
// that‘s all folks
return 0;
}
/*
* Clears screen using ANSI escape sequences.
*/
void
clear(void)
{
printf(“ 33[2J“);
printf(“ 33[%d;%dH“ 0 0);
}
/*
* Greets player.
*/
void
greet(void)
{
clear();
printf(“WELCOME TO THE GAME OF FIFTEEN
“);
usleep(2000000);
}
/*
* Initializes the game‘s board with tiles numbered 1 through d*d - 1
* (i.e. fills 2D array with values but does not actually print them).
*/
void
init(void)
{
// TODO
}
/*
* Prints the board in its current state.
*/
void
draw(void)
{
// TODO
}
/*
* If tile borders empty space moves tile and returns true else
* returns false.
*/
bool
move(int tile)
{
// TODO
return false;
}
/*
* Returns true if game is won (i.e. board is in winning configuration)
* else false.
*/
bool
won(void)
{
// TODO
return false;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2916 2011-02-12 14:21 pset4debug.bin
文件 331776 2011-02-12 14:21 pset4l33t.bin
文件 239 2011-09-30 06:33 pset4Makefile
文件 331776 2011-02-12 14:21 pset4
00b.bin
文件 12537 2011-02-12 14:21 pset4sudoku.c
文件 751 2011-02-12 14:21 pset4sudoku.h
文件 2013 2010-10-15 18:31 pset5mpmp.h
文件 921656 2010-10-15 18:22 pset5mpclue.bmp
文件 2595 2010-10-15 18:21 pset5mpcopy.c
文件 486 2010-10-15 18:21 pset5mplarge.bmp
文件 429 2010-10-15 18:23 pset5mpMakefile
文件 90 2010-10-15 18:21 pset5mpsmall.bmp
文件 246 2010-10-15 18:21 pset5mpsmiley.bmp
文件 0 2010-10-15 18:32 pset5questions.txt
文件 852 2010-10-23 10:31 pset6dictionary.c
文件 871 2010-10-23 10:31 pset6dictionary.h
文件 662 2010-10-23 10:31 pset6Makefile
文件 0 2010-10-23 10:31 pset6questions.txt
文件 5141 2010-10-23 10:31 pset6speller.c
文件 167529 2010-09-11 13:15 pset6 extsalice.txt
文件 704132 2010-09-11 13:15 pset6 extsausten.txt
文件 159309 2010-09-11 13:15 pset6 extsaustinpowers.txt
文件 182029 2010-09-11 13:15 pset6 extschristmas.txt
文件 45118 2010-09-11 13:15 pset6 extsconstitution.txt
文件 875 2010-09-11 13:15 pset6 extsdaffodils.txt
文件 874627 2010-09-11 13:15 pset6 extsdracula.txt
文件 1205891 2010-09-11 13:15 pset6 extsfederalist.txt
文件 463156 2010-09-11 13:15 pset6 extsfrankenstein.txt
文件 532695 2010-09-11 13:15 pset6 extsgrimm.txt
文件 6617503 2010-09-11 13:15 pset6 extsholmes.txt
............此处省略177个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)