重言式判断

/*问题描述:一个逻辑表达式如果对于其变元的任一种取值都为真,则称为重言式;反之,如果对于其变元的任一种取值都为假,则称为矛盾式;然而,更多情况下,既非重言式,也非矛盾式。逻辑表达式从终端输入,长度不超过一行。逻辑运算符包括“|”,“&”,“~”,分别表示或、与和非,运算优先程度递增,但可以由括号改变,即括号内的运算优先。逻辑变元为大写字母。表达式中任何地方都可以包含多个空格符。若是重言式或矛盾式,则显示“True forever”或“False forever”,否则显示“Statisfactible”以及变量名序列,供用户输入各变量名的值,程序然后显示表达式的值?*/#inc...
程序 | 2010-12-08 17:46 | 阅读 843 次 | 评论 0 条

魔王语言

#include <stdio.h>#define StackElementType char#define Stack_Size 100typedef struct{StackElementType elem[Stack_Size];int top;}SeqStack;void InitStack(SeqStack *s);/*初始化栈*/void Push(SeqStack *s,StackElementType x); /*进栈操作*/void Pop(SeqStack *s,StackElementType *x);/*出栈操作*/void GetTop(SeqStack *...
程序 | 2010-12-08 17:24 | 阅读 824 次 | 评论 0 条

任何进制转换

#include <stdio.h>#include <stdlib.h>#define MAXS 8//#define ADD 8//typedef struct { char *base; char *top; int stacksize;}Sqstack;void InitStack( Sqstack &amp;s){ s.base = (char *) malloc (MAXS*sizeof(char)); if( !s.base ) exit(0); s.top = s.base; s.stacksize = MAX...
程序 | 2010-12-08 17:21 | 阅读 707 次 | 评论 0 条

八皇后问题的一解

#include <stdio.h>#include <conio.h>#define TRUE 1#define FALSE 0#define MAXQUEEN 8#define ABS(x) ((x>0)?(x):-(x))int queen[MAXQUEEN];int total_solution;void place(int);int attack(int,int);void output_solution();void main(void){ place(0);}void place(int q){ int i; i=0; while (i<MAX...
程序 | 2010-12-08 17:19 | 阅读 665 次 | 评论 0 条

迷宫

//*laoshu.h 系统主文件//迷宫用字符型二维数组存储//迷宫随机生成//其中"*"表示墙//" "表示路//"=="表示走过的无用的路//"+"表示走过的有用的路//"^"表示当前老鼠所在的位置//TIMEMAX可以设定执行速度#include<iostream.h>#include<stdlib.h>#include<process.h>#include<time.h>#include<malloc.h>#define TIMEMAX 6000#define OK 0#define ERROR -1#define UP 1#define DOWN 2#define LEF...
程序 | 2010-12-08 17:15 | 阅读 581 次 | 评论 0 条

马踏棋盘

马踏棋盘程序设计 完美 1.问题描述设计一个国际象棋的马踏棋盘的演示程序2.需求分析(1)将马随即放在国际象棋的8×8棋盘Board[8][8]的某个方格中,马按走棋规则进行移动。要求每个方格只进入一次,走遍棋盘上全部64个方格。(2)编制非递归程序,求出马的行走路线,并按求出的行走路线,将数字1,2,……,64依次填入一个8×8的方阵,输出之。(3)程序执行命令为: 1)输入起始方格坐标(X,Y)2)求解第一组路径并显示,按Q键退出系统,按其他任意键求解并显示下一组路径。(4)测试数据:(0,0),(1,2)3概要设计3.1[程序设计思路].按照顺时针顺序,每次产生一个新的路点...
程序 | 2010-12-08 17:07 | 阅读 760 次 | 评论 0 条

贪吃蛇

#include <iostream.h>#include <time.h>#include <conio.h>#include <windows.h>#include <stdio.h>const int LENGTH = 25;//最大的图class SNAKE{public: SNAKE():size(10),s1(1),s2(1){} int step(); int init(); int show(); int change();private: int size; int table[LENGTH][LENGTH]; int...
程序 | 2010-12-08 14:23 | 阅读 604 次 | 评论 0 条

算术表达式求值

#include<stdlib.h>#include<stdio.h>#define stack_init_size1 40#define stack_init_size2 20#define stackincrement1 40#define stackincrement2 20typedef struct{ int *base; int *top; int stacksize;}s_stack;typedef struct{ char *base; char *top; int stacksize;}f_stack;static char yo...
程序 | 2010-12-08 14:17 | 阅读 586 次 | 评论 0 条

计算24点

/*--------------------------------------------------------------------- 24点游戏程序之一对于点数不超过10的4张扑克牌,如有解,输出一种算法;否则,输出“failure”----------------------------------------------------------------------*/#include <stdio.h>#include <math.h>#include <string.h>typedef int logic;int ss[]...
程序 | 2010-12-08 14:13 | 阅读 831 次 | 评论 0 条
浏览29753次