自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(23)
  • 收藏
  • 关注

原创 贪吃蛇-控制台

本文把游戏区域就行编号,第一行从0到WIDTH-1,…… 到HEIGHT-1 到 WIDTH*HEIGHT-1(二维数组)。并用trace[LEN]数组保存snake移动的轨迹(保存的是数值,数值就能表现出所在的行和列),(trace[0]始终为snake的头部),根据display()函数绘图,延时,在绘图,达到刷新屏幕的效果。#include <stdio.h>#include <stdlib

2016-04-16 10:28:30 390

原创 c语言俄罗斯方块

一直以来都想做的东西。 参考了:http://blog.csdn.net/l04205613/article/details/6972061 这些符号:■ □ → ← ↓ ↑ 用了搜狗输入法中的特殊符号, 水平2个字符, 垂直1个字符。//tetris.c#include <stdio.h>#include <stdlib.h> #include <string.h> // fo

2016-01-23 23:58:06 1781

原创 2048简易控制台

//2048.c#include <stdio.h>#include <stdlib.h>#include <conio.h> // for getch()int a[4][4] = {0}, b[4][4] = {0};int score = 0;int steps = 0;void num_rand();void display();void runGame();voi

2016-01-22 19:03:00 412

原创 五子棋

// gobang.c#include <stdio.h>#include <stdlib.h>#include <conio.h> // for getch()#define LEN 21int play1 = 1, play2 = 2; char chess[LEN][LEN];unsigned int x = LEN/2, y = LEN/2; // cursor Po

2016-01-21 16:22:17 305

原创 万年历

// calendar.c#include <stdio.h>char *month_name[] = {"illegal Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "Novemb

2016-01-19 22:03:57 262

原创 任意匹配

找出两字符串任意匹配的最长项.#include <stdio.h>#include <string.h>char *str_match(char *s, char *t){ static char line[100], max_match[100]; int is, j, k, it, il, max = 0; for (is = 0; is < strlen(s); i

2015-09-13 13:00:21 385

原创 Going Graphical — The dialog Utility

dialog --msgbox “Hello World” 9 18The principal types of dialogs you can create are described in the following table: Type Option Used to Create Type Meaning Check boxes –checklist Allows yo

2015-09-05 19:52:49 291

原创 shell syntax

1.Variablesxxx@xxx-pc ~ $ salutation=helloxxx@xxx-pc ~ $ echo $salutation helloxxx@xxx-pc ~ $ read salutationwhat? //user inxxx@xxx-pc ~ $ echo $salutation what?Try It Out:#!/bin/shmyv

2015-09-04 20:14:28 502

原创 变长参数

标准头文件<stdarg.h>包含一组宏定义, 它们对如何遍历参数表进行了定义.va_list ap; //参数指针宏va_start 将ap初始化为指向第一个无名参数的指针,使用ap之前,va_start必须被调用一次.参数表至少包含一个有名参数,va_start将最后一个有名参数作为起点.每次调用va_arg,该函数都返回一个参数, 并将ap 指向下一个参数. va_arg使用一个类型名来决定

2015-09-03 23:35:07 253

原创 常用函数

7.8. 其它函数标准库提供了很多功能各异的函数。本节将对其中特别有用的函数做一个简要的概述。 更详细的信息以及其它许多没有介绍的函数请参见附录 B。7.8.1. 字符串操作函数7.8.2. 字符类别测试和转换函数头文件7.8.3. ungetc 函数标准库提供了一个称为 ungetc 的函数,它与第 4 章中编写的函数 ungetch 相比功能更 受限制。 int ungetc(int c,

2015-09-02 15:09:19 210

原创 stdin, stdout, stderror

cat x.c y.c/* <stdio.h> include a structure declaration called FILE. (with a typedef) */FILE *fp;/* read ("r"), write ("w"), and append ("a") */FILE *fopen (char *name, char *mode);int fclose(FILE

2015-09-02 14:43:49 763

原创 typedef union bit-field

1. typedeftypedef struct tnode *Treeptr;typedef struct tnode { char *word; int count; struct tnode *left; struct tnode *right;} Treenode; /* Treenode (a structure) and Treeptr (a point

2015-08-31 21:49:40 753

原创 shell programing

$ /bin/bash –versionPipes and Redirection $ ls -l > lsoutput.txtfile descriptor 0 is the standard input file descriptor 1 is the standard output file descriptor 2 is the standard error set can

2015-08-29 14:23:33 336

原创 库编译

Header Filesuse header files in subdirectories or nonstandard places by specifying the -I flag (for include ) gcc -I/usr/openwin/include/ fred.cgrep searches all the files in the directory with a na

2015-08-28 19:11:29 311

原创 命令行参数

按照 C 语言的约定,argv[0]的值是启动该程序的程序名,因此 argc 的值至少为 1。 如果 argc 的值为 1,则说明程序名后面没有命令行参数。在上面的例子中,argc 的值为 3, argv[0]、argv[1]和 argv[2]的值分别为“echo”、 “hello,”,以及“world” 。第一个可选参数为 argv[1],而最后一个可选参数为 argv[argc-1]。另外

2015-08-25 22:15:21 327

原创 指针数组

5.6.指针数组以及指向指针的指针 —– 文本排序#include <stdio.h>#include <string.h>#define MAXLINES 5000 /* max #lines to be sorted */char *lineptr[MAXLINES]; /* pointers to text lines */int readlines(char *s[], int nl

2015-08-25 10:43:37 253

原创 string函数

string函数/* strcpy: copy t to s */char *strcpy(char *s, char *t){ char *p = s; while(*s++ = *t++) ; return p;}/* strcmp: return <0 if s<t, 0 if s==t, >0 if s>t

2015-08-22 22:30:34 207

原创 alloc

5.4 alloc#define ALLOCSIZE 10000 /* size of available space */static char allocbuf[ALLOCSIZE];static char *allocp = allocbuf;char *alloc(int n) /* return pointer to n characters */{ if(a

2015-08-22 21:18:18 246

原创 递归

练习 4-12 运用 printd 函数的设计思想编写一个递归版本的 itoa 函数, 即通过递归 调用把整数转换为字符串。 练习 4-13 编写一个递归版本的 reverse(s)函数,以将字符串 s 倒置。include <stdio.h>#include <string.h>int i = 0;void itoa(int n, char s[]){ if(n <

2015-08-21 23:08:41 362

原创 文章标题

4.3节 Polish calculator.#include <stdio.h>#include <stdlib.h> /* for atof() */#define MAXOP 100 /* max size of operand or operator */#define NUMBER '0' /* signal that a number was found */int getop

2015-08-21 00:37:38 230

原创 文章标题

练习 3-4 在数的对二的补码表示中,我们编写的 itoa 函数不能处理最大的负数,即字长n 等于-2 -1 的情况。请解释其原因。修改该函数,使它在任何机器上运行时都能打印出正确的值。#include <stdio.h>#include <string.h>void reverse(char []);void itoa(int , char []);int main(){

2015-08-17 21:40:34 197

原创 文章标题

练习 2-4 都删除。 squeeze(s1, s2),将字符串 s1 中任何与字符串 s2 中字符匹配的字符 练习 2-5 编写函数 any(s1, s2),将字符串 s2 中的任一字符在字符串 s1 中第一次 出现的位置作为结果返回。 如果 s1 中不包含 s2 中的字符, 则返回-1。 (标准库函数 strpbrk具有同样的功能,但它返回的是指向该位置的指针。)#include <

2015-08-16 22:21:13 170

原创 文章标题

练习 2-3 编写函数 htoi(s),把由十六进制数字组成的字符串(包含可选的前缀 0x 或 0X)转换为与之等价的整型值。字符串中允许包含的数字包括:0~9、a~f 以及 A~F。#include <stdio.h>/* htoi: convert s to integer */int htoi(char s[]){ int i, n; n = 0; i = 0;

2015-08-16 21:41:03 210

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除