c语言简单pos机下载
1、c语言,编写一个售货机(POS)计算程序,用于水果店售货员算账.苹果每千克...
#include <stdio.h>
int main(void)
{
float p[4] = {3.2, 1.96, 3, 24};
float w[4] = {1.5, 2, 3, 1.5};
float s = 0;
int i;
for(i=0;i<4;i++)
s+= p[i]*w[i];
printf("%s%12s%12s%13s\n", "名称", "单价", "重量", "应付价钱");
printf("---------------------------------------------\n");
printf("%s%12.2f%12.2f%13.3f\n","苹果", p[0], w[0], p[0]*w[0]);
printf("%s%12.2f%12.2f%13.3f\n","梨 ", p[1], w[1], p[1]*w[1]);
printf("%s%12.2f%12.2f%13.3f\n","香蕉", p[2], w[2], p[2]*w[2]);
printf("%s%12.2f%12.2f%13.3f\n","樱桃", p[3], w[3], p[3]*w[3]);
printf("---------------------------------------------\n");
printf("%s%37.2f\n", "总计", s);
printf("%s%37.2f\n", "付款", 100.0);
printf("%s%37.2f\n", "找零", 100.0 - s);
return 0;
}
2、C语言编写的收银台结算程序。
//以下是参考代码有相似结构,数据结构自己设计一下。
//如果没参考价值,手下留情,别点不采纳。
#define MAXPARKINGPOS 100
#define MAXPRICETYPE 3
#define MAXLINE 4096
struct detail
{
char num[MAXLINE];
char name[MAXLINE];
double pricePerHour;
time_t start;
time_t end;
double period;
double cost;
};
static int currentParkingNum = 0;
static struct detail detailBuf[MAXPARKINGPOS];
static double priceBuf[MAXPRICETYPE] = {11.0,22.0,33.0};
int main(void) {
char buf[MAXLINE];
struct detail *myParking;
int iChoice,leavingIndex,i,numEexisted;
struct tm *begin,*end;
while(true) {
selectService:
printf("Service type,what is your choice?\n1.park\n2.leave\n3.exit\n");
gets(buf);
if(strcmp(buf,"3") == 0) {
return 0;
}
if(strcmp(buf,"1") == 0) {
//park
if(currentParkingNum == MAXPARKINGPOS) {
printf("Sorry,not empty!\n\n");
continue;
}
myParking = detailBuf+currentParkingNum;
printf("your name:\n");
gets(myParking->name);
printf("your parking num:\n");
gets(myParking->num);
numEexisted = 0;
for(i=0;i<currentParkingNum;i++) {
if(strcmp(detailBuf[i].num,myParking->num) == 0) {
numEexisted =1;
break;
}
}
if(numEexisted != 0) {
printf("The car %s is in\n\n",myParking->num);
goto selectService;
}
selectPrice:
printf("Service cost,what is your choice?\n");
for(int i=0;i < MAXPRICETYPE; i++) {
printf("%d.$%.2f per hour\n",i+1,priceBuf[i]);
}
gets(buf);
iChoice = atoi(buf);
if(!(iChoice >= 1 && iChoice <=MAXPRICETYPE)) {
printf("Your choice is incorrect!\n\n");
goto selectPrice;
}
myParking->pricePerHour=priceBuf[iChoice-1];
time(&myParking->start);
currentParkingNum++;
printf("Parcking ok!\n\n");
}else if(strcmp(buf,"2") == 0) {
//leave
printf("your parking num:\n");
gets(buf);
myParking = NULL;
for(i=0;i<currentParkingNum;i++) {
if(strcmp(detailBuf[i].num,buf) == 0) {
myParking = &detailBuf[i];
leavingIndex = i;
break;
}
}
if(myParking ==NULL) {
printf("Cannot find your car!\n\n");
continue;
}
myParking->end = time(&myParking->end);
myParking->period = difftime(myParking->end,myParking->start);
myParking->cost= myParking->period/3600.0*myParking->pricePerHour;
printf("****** Cost Details ******\n");
printf("name:%s\n",myParking->name);
printf("number:%s\n",myParking->num);
printf("price:%.2f\n",myParking->pricePerHour);
begin = localtime(&myParking->start);
strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",begin);
printf("begin:%s\n",buf);
end = localtime(&myParking->end);
strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",end);
printf("end:%s\n",buf);
printf("period:%.2f hour(s)\n",myParking->period/3600.0);
printf("cost:$%.2f\n",myParking->cost);
printf("service:$%.2f per hour\n",myParking->pricePerHour);
for(i = leavingIndex; i < currentParkingNum;i++) {
if(i+1 < currentParkingNum) {
detailBuf[i]=detailBuf[i+1];
}
}
detailBuf[currentParkingNum-1].cost=0.0;
detailBuf[currentParkingNum-1].end=0;
detailBuf[currentParkingNum-1].name[0]='\0';
detailBuf[currentParkingNum-1].num[0]='\0';
detailBuf[currentParkingNum-1].period=0.0;
detailBuf[currentParkingNum-1].pricePerHour=0.0;
detailBuf[currentParkingNum-1].start=0;
currentParkingNum--;
printf("Leaving ok!\n\n");
}else{
printf("Your choice is incorrect!\n\n");
continue;
}
}
return 0;
}
建立商品库
建立出售库
每刷一毛,查询商品库,记录出售库。。。。。直到结算,开始新一笔。。。。。。。。。。如此循环
C++的要不要?
C的太麻烦了,除非就实现简单的功能
3、c语言中pos是什么意思
位置。pos是position的缩写,意思是位置,主要用在标准库函数find中,多用于查找位置。语言是由词按照一定的语言规则所组成的符号系统,如汉语、英语、 俄语 等。4、求C语言小游戏源程序
简易“推箱子”游戏C代码:
#include <stdio.h>
#include <conio.h>
#include<stdlib.h>
#include<windows.h>
int m =0; //m代表第几关
struct maps{short a[9][11]; };
struct maps map[5]={ 0,0,0,0,0,0,0,0,0,0,0, //共5关,每关9行
0,1,1,1,1,1,1,1,0,0,0,
0,1,0,0,0,0,0,1,1,1,0,
1,1,4,1,1,1,0,0,0,1,0, //0空地,1墙
1,5,0,0,4,0,0,4,0,1,0, //4是箱子,5是人
1,0,3,3,1,0,4,0,1,1,0, //3是目的地
1,1,3,3,1,0,0,0,1,0,0, //7是箱子在目的地(4+3)
0,1,1,1,1,1,1,1,1,0,0, //8是人在目的地(5+3)
0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,1,0,0,0,0,0,
0,0,1,5,0,1,1,1,0,0,0,
0,0,1,0,4,0,0,1,0,0,0,
0,1,1,1,0,1,0,1,1,0,0,
0,1,3,1,0,1,0,0,1,0,0,
0,1,3,4,0,0,1,0,1,0,0,
0,1,3,0,0,0,4,0,1,0,0,
0,1,1,1,1,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,0,0,0,
0,0,0,1,1,1,1,1,1,1,0,
0,0,1,1,0,0,1,0,5,1,0,
0,0,1,0,0,0,1,0,0,1,0,
0,0,1,4,0,4,0,4,0,1,0,
0,0,1,0,4,1,1,0,0,1,0,
1,1,1,0,4,0,1,0,1,1,0,
1,3,3,3,3,3,0,0,1,0,0,
1,1,1,1,1,1,1,1,1,0,0,
0,1,1,1,1,1,1,1,1,1,0,
0,1,0,0,1,1,0,0,0,1,0,
0,1,0,0,0,4,0,0,0,1,0,
0,1,4,0,1,1,1,0,4,1,0,
0,1,0,1,3,3,3,1,0,1,0,
1,1,0,1,3,3,3,1,0,1,1,
1,0,4,0,0,4,0,0,4,0,1,
1,0,0,0,0,0,1,0,5,0,1,
1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,
0,0,0,1,1,1,1,1,1,0,0,
0,1,1,1,0,0,0,0,1,0,0,
1,1,3,0,4,1,1,0,1,1,0,
1,3,3,4,0,4,0,0,5,1,0,
1,3,3,0,4,0,4,0,1,1,0,
1,1,1,1,1,1,0,0,1,0,0,
0,0,0,0,0,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,0,0,0 };
void DrMap( ) //绘制地图
{ CONSOLE_CURSOR_INFO cursor_info={1,0}; //隐藏光标的设置
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
printf("\n\n \t\t\b推箱子");
printf("\n \t");
for (int i = 0; i < 9; i++)
{for (int j = 0; j < 11; j++)
{switch (map[m].a[i][j])
{case 0: printf(" "); break;
case 1: printf("■"); break;
case 3: printf("◎");break;
case 4: printf("□"); break;
case 5: printf("♀"); break; //5是人
case 7: printf("□"); break; //4 + 3箱子在目的地中
case 8: printf("♀");break; // 5 + 3人在目的地中
}
}
printf("\n\t");
}
}
void gtxy(int x, int y) //控制光标位置的函数
{ COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void start( ) //开始游戏
{ int r, c; //存储人的下标
for (int i = 0; i < 9; i++)
{ for (int j = 0; j < 11; j++)
{if (map[m].a[i][j] == 5||map[m].a[i][j]==8) { r = i; c = j; } } //i j 人的下标
}
char key;
key = getch( );
switch (key)
{case 'W':
case 'w':
case 72:
if (map[m]. a[r - 1][c] == 0|| map[m]. a [r - 1][c] == 3)
{ gtxy(2*c+8,r-1+3); printf("♀"); // gtxy(2*c+8,r-1+3)是到指定位置输出字符
if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf(" "); }
if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}
map[m]. a [r - 1][c] += 5; map[m]. a [r][c] -= 5; }
else if (map[m]. a [r - 1][c] == 4 || map[m]. a [r - 1][c] == 7)
{ if (map[m]. a [r - 2][c] == 0 || map[m]. a [r - 2][c] == 3)
{ gtxy(2*c+8,r-2+3); printf("□"); gtxy(2*c+8,r-1+3); printf("♀");
if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf(" "); }
if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}
map[m]. a [r - 2][c] += 4; map[m]. a [r - 1][c] += 1;
map[m]. a [r][c] -= 5; }
} break;
case 'S':
case 's':
case 80:
if (map[m]. a [r + 1][c] == 0 || map[m]. a [r + 1][c] == 3)
{ gtxy(2*c+8,r+1+3); printf("♀");
if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf(" "); }
if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}
map[m]. a [r + 1][c] += 5; map[m]. a [r][c] -= 5; }
else if (map[m]. a [r + 1][c] == 4 || map[m]. a [r+ 1][c] == 7)
{ if (map[m]. a [r + 2][c] == 0 || map[m]. a [r + 2][c] == 3)
{ gtxy(2*c+8,r+2+3); printf("□"); gtxy(2*c+8,r+1+3); printf("♀");
if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf(" "); }
if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}
map[m]. a [r + 2][c] += 4; map[m]. a [r + 1][c] += 1;
map[m]. a [r][c] -= 5; }
}break;
case 'A':
case 'a':
case 75:
if (map[m]. a [r ][c - 1] == 0 || map[m]. a [r ][c - 1] == 3)
{ gtxy(2*(c-1)+8,r+3); printf("♀");
if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf(" "); }
if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}
map[m]. a [r ][c - 1] += 5; map[m]. a [r][c] -= 5; }
else if (map[m]. a [r][c - 1] == 4 || map[m]. a [r][c - 1] == 7)
{if (map[m]. a [r ][c - 2] == 0 || map[m]. a [r ][c - 2] == 3)
{ gtxy(2*(c-2)+8,r+3); printf("□"); gtxy(2*(c-1)+8,r+3); printf("♀");
if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf(" "); }
if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}
map[m]. a [r ][c - 2] += 4; map[m]. a [r ][c - 1] += 1;
map[m]. a [r][c] -= 5; }
}break;
case 'D':
case 'd':
case 77:
if (map[m]. a [r][c + 1] == 0 || map[m]. a [r][c + 1] == 3)
{ gtxy(2*(c+1)+8,r+3); printf("♀");
if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf(" "); }
if(map[m]. a[r ][c] == 8) {gtxy(2*c+8,r+3); printf("◎");}
map[m]. a [r][c + 1] += 5; map[m]. a [r][c] -= 5; }
else if (map[m]. a [r][c + 1] == 4 || map[m]. a [r][c + 1] == 7)
{ if (map[m]. a [r][c + 2] == 0 || map[m]. a [r][c + 2] == 3)
{ gtxy(2*(c+2)+8,r+3); printf("□"); gtxy(2*(c+1)+8,r+3); printf("♀");
if(map[m]. a[r ][c] == 5){gtxy(2*c+8,r+3); printf(" "); }
if(map[m]. a[r ][c] == 8){gtxy(2*c+8,r+3); printf("◎");}
map[m]. a [r][c + 2] += 4; map[m]. a [r][c + 1] += 1;
map[m]. a [r][c] -= 5; }
}break;
}
}
int ifwan( ) //是否完成(1是0否)
{ if(m==0){if(map[m].a[5][2]==7&& map[m].a[5][3]==7&&
map[m].a[6][2]==7&& map[m].a[6][3]==7) return 1;}
if(m==1){if(map[m].a[5][2]==7&& map[m].a[6][2]==7&&
map[m].a[7][2]==7) return 1;}
if(m==2){if(map[m].a[7][1]==7&& map[m].a[7][2]==7&& map[m].a[7][3]==7&&
map[m].a[7][4]==7&& map[m].a[7][5]==7) return 1;}
if(m==3){if(map[m].a[4][4]==7&& map[m].a[4][5]==7&& map[m].a[4][6]==7&&
map[m].a[5][4]==7&& map[m].a[5][5]==7&& map[m].a[5][6]==7) return 1;}
if(m==4){if(map[m].a[3][2]==7&& map[m].a[4][1]==7&& map[m].a[4][2]==7&&
map[m].a[5][1]==7&& map[m].a[5][2]==7) return 1;}
return 0;
}
int main( ) //主函数
{ while (1)
{ system("cls");
DrMap( );
while (1)
{ start( );
if(ifwan()){printf("\007");break;} //完成后响铃
}
m+=1;
}
return 0;
}
学习一下数字版“拼图”代码写法:
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
int i, j, r, k; //i、j、r用于循环, k存放随机数值
int m, n; // m、n是当前空位的下标
int a[4][4]; //存储4×4共16个数字的数组
void show(void); //输出数组表格
void csh(void); //初始化界面
int yes(void); //判断排序是否成功
void up(void); //数字向上移动到空位(空位则下移)
void down(void); //数字向下移
void left(void); //数字向左移
void rght(void); //数字向右移
void inkey(void); //按键操作
void gtxy(int x, int y) ; //控制光标位置的函数
int main(void)
{ while(1)
{ csh( );
while(1)
{ inkey();
show();
if ( yes( ) )
{gtxy(6,12); printf("你成功了! 再来一局y/n?"); break;}
}
if(getch( )== 'n')break;
}
return 0;
}
void csh(void) //初始化界面
{ r=0;
CONSOLE_CURSOR_INFO cursor_info={1,0}; //以下两行是隐藏光标的设置
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
for(i=0;i<4;i++) //给数组a依序赋值
for(j=0;j<4;j++)
{ if (i==3 && j==3) a[i][j]=0;
else a[i][j]=1+r++;
}
m=3; n=3; //记下空格(值为0)的下标
down( ); rght( ); rght( ); down( ); //预演4步
srand((unsigned)time(0)); //初始化随机数发生器
for(r=0;r<500;r++) //将数组各值打乱
{ k=rand( )%(4);
switch(k)
{ case 0: { up( ); break; }
case 1: {down( ); break; }
case 2: { left( ); break; }
case 3: { rght( ); break; }
}
}
system("cls");
printf("\n\n\t\t 数字拼图");
printf("\n\t┌──────┬──────┬──────┬──────┐");
printf("\n\t│ │ │ │ │");
printf("\n\t├──────┼──────┼──────┼──────┤");
printf("\n\t│ │ │ │ │");
printf("\n\t├──────┼──────┼──────┼──────┤");
printf("\n\t│ │ │ │ │");
printf("\n\t├──────┼──────┼──────┼──────┤");
printf("\n\t│ │ │ │ │");
printf("\n\t└──────┴──────┴──────┴──────┘");
show( );
}
void show(void) //输出界面
{for(i=0;i<4;i++)
for(j=0;j<4;j++) //gtxy(7*j+9, 2*i+4)是光标到指定位置输出数字
{gtxy(7*j+9,2*i+4); if(a[i][j]==0)printf(" │");
else if(a[i][j]>9)printf(" %d │",a[i][j]);
else printf(" %d │",a[i][j]);
}
}
void inkey(void) //按键操作
{ int key;
key=getch( );
switch(key)
{ case 72: { up( ); break; }
case 80: {down( ); break; }
case 75: {left( ); break; }
case 77: { rght( ); break; }
}
}
void up(void) //数字向上移
{ if (m!=3) //空位不得在下边界
{ a[m][n]=a[m+1][n]; m++; a[m][n]=0; }
}
void down(void) //数字向下移
{ if (m!=0) //空位不得在上边界
{a[m][n]=a[m-1][n]; m--; a[m][n]=0; }
}
void left(void) //数字向左移
{ if (n!=3) //空位不得在右边界
{ a[m][n]=a[m][n+1]; n++; a[m][n]=0; }
}
void rght(void) //数字向右移
{ if (n!=0) //空位不得在左边界
{ a[m][n]=a[m][n-1]; n--; a[m][n]=0; }
}
int yes(void) //判断排序是否成功
{ r=0;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
{ if (a[i][j]!=1+r++) return (r==16)?1:0; }
}
void gtxy(int x, int y) //控制光标位置的函数
{ COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
我的楼主可以自己玩一下试试吧
#define N 200
#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define ESC 0x011b
int i,key;
int score=0;/*得分*/
int gamespeed=50000;/*游戏速度自己调整*/
struct Food
{
int x;/*食物的横坐标*/
int y;/*食物的纵坐标*/
int yes;/*判断是否要出现食物的变量*/
}food;/*食物的结构体*/
struct Snake
{
int x[N];
int y[N];
int node;/*蛇的节数*/
int direction;/*蛇移动方向*/
int life;/* 蛇的生命,0活着,1死亡*/
}snake;
void Init(void);/*图形驱动*/
void Close(void);/*图形结束*/
void DrawK(void);/*开始画面*/
void GameOver(void);/*结束游戏*/
void GamePlay(void);/*玩游戏具体过程*/
void PrScore(void);/*输出成绩*/
/*主函数*/
void main(void)
{
Init();/*图形驱动*/
DrawK();/*开始画面*/
GamePlay();/*玩游戏具体过程*/
Close();/*图形结束*/
}
/*图形驱动*/
void Init(void)
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
cleardevice();
}
/*开始画面,左上角坐标为(50,40),右下角坐标为(610,460)的围墙*/
void DrawK(void)
{
/*setbkcolor(LIGHTGREEN);*/
setcolor(11);
setlinestyle(SOLID_LINE,0,THICK_width="360px",height="auto" /> for(i=50;i<=600;i+=10)/*画围墙*/
{
rectangle(i,40,i+10,49); /*上边*/
rectangle(i,451,i+10,460);/*下边*/
}
for(i=40;i<=450;i+=10)
{
rectangle(50,i,59,i+10); /*左边*/
rectangle(601,i,610,i+10);/*右边*/
}
}
/*玩游戏具体过程*/
void GamePlay(void)
{
randomize();/*随机数发生器*/
food.yes=1;/*1表示需要出现新食物,0表示已经存在食物*/
snake.life=0;/*活着*/
snake.direction=1;/*方向往右*/
snake.x[0]=100;snake.y[0]=100;/*蛇头*/
snake.x[1]=110;snake.y[1]=100;
snake.node=2;/*节数*/
PrScore();/*输出得分*/
while(1)/*可以重复玩游戏,压ESC键结束*/
{
while(!kbhit())/*在没有按键的情况下,蛇自己移动身体*/
{
if(food.yes==1)/*需要出现新食物*/
{
food.x=rand()%400+60;
food.y=rand()%350+60;
while(food.x%10!=0)/*食物随机出现后必须让食物能够在整格内,这样才可以让蛇吃到*/
food.x++;
while(food.y%10!=0)
food.y++;
food.yes=0;/*画面上有食物了*/
}
if(food.yes==0)/*画面上有食物了就要显示*/
{
setcolor(GREEN);
rectangle(food.x,food.y,food.x+10,food.y-10);
}
for(i=snake.node-1;i>0;i--)/*蛇的每个环节往前移动,也就是贪吃蛇的关键算法*/
{
snake.x[i]=snake.x[i-1];
snake.y[i]=snake.y[i-1];
}
/*1,2,3,4表示右,左,上,下四个方向,通过这个判断来移动蛇头*/
switch(snake.direction)
{
case 1:snake.x[0]+=10;break;
case 2: snake.x[0]-=10;break;
case 3: snake.y[0]-=10;break;
case 4: snake.y[0]+=10;break;
}
for(i=3;i<snake.node;i++)/*从蛇的第四节开始判断是否撞到自己了,因为蛇头为两节,第三节不可能拐过来*/
{
if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])
{
GameOver();/*显示失败*/
snake.life=1;
break;
}
}
if(snake.x[0]<55||snake.x[0]>595||snake.y[0]<55||
snake.y[0]>455)/*蛇是否撞到墙壁*/
{
GameOver();/*本次游戏结束*/
snake.life=1; /*蛇死*/
}
if(snake.life==1)/*以上两种判断以后,如果蛇死就跳出内循环,重新开始*/
break;
if(snake.x[0]==food.x&&snake.y[0]==food.y)/*吃到食物以后*/
{
setcolor(0);/*把画面上的食物东西去掉*/
rectangle(food.x,food.y,food.x+10,food.y-10);
snake.x[snake.node]=-20;snake.y[snake.node]=-20;
/*新的一节先放在看不见的位置,下次循环就取前一节的位置*/
snake.node++;/*蛇的身体长一节*/
food.yes=1;/*画面上需要出现新的食物*/
score+=10;
PrScore();/*输出新得分*/
}
setcolor(4);/*画出蛇*/
for(i=0;i<snake.node;i++)
rectangle(snake.x[i],snake.y[i],snake.x[i]+10,
snake.y[i]-10);
delay(gamespeed);
setcolor(0);/*用黑色去除蛇的的最后一节*/
rectangle(snake.x[snake.node-1],snake.y[snake.node-1],
snake.x[snake.node-1]+10,snake.y[snake.node-1]-10);
} /*endwhile(!kbhit)*/
if(snake.life==1)/*如果蛇死就跳出循环*/
break;
key=bioskey(0);/*接收按键*/
if(key==ESC)/*按ESC键退出*/
break;
else
if(key==UP&&snake.direction!=4)
/*判断是否往相反的方向移动*/
snake.direction=3;
else
if(key==RIGHT&&snake.direction!=2)
snake.direction=1;
else
if(key==LEFT&&snake.direction!=1)
snake.direction=2;
else
if(key==DOWN&&snake.direction!=3)
snake.direction=4;
}/*endwhile(1)*/
}
/*游戏结束*/
void GameOver(void)
{
cleardevice();
PrScore();
setcolor(RED);
settextstyle(0,0,4);
outtextxy(200,200,"GAME OVER");
getch();
}
/*输出成绩*/
void PrScore(void)
{
char str[10];
setfillstyle(SOLID_FILL,YELLOW);
bar(50,15,220,35);
setcolor(6);
settextstyle(0,0,2);
sprintf(str,"score:%d",score);
outtextxy(55,20,str);
}
/*图形结束*/
void Close(void)
{
getch();
closegraph();
}
新手要方便写代码,可以收藏下面几个自编函数:
gtxy (6, 3) //光标定位于窗口的第6列,第3行处(准备输出,行与列都是从0算起)
Color (4, 0) //设置为红字配黑底 如 Color (10, 0)则是淡绿字配黑底
yinc (1,0) //隐藏光标(第二个参数设为0就隐藏,没有光标闪烁,yinc代表隐藏)
kou(80,25) //设定窗口缓冲区大小为80列,25行
下面几个是库函数,不需自己编写,只要用#include包含就可以使用。
SetConsoleTitle("俄罗斯方块"); //设置窗口左上角标题栏处出现"俄罗斯方块"5个字
srand( (unsigned) time(NULL) ); //初始化随机数发生器
n= rand( ) % 20; //产生随机数0-19中的一个. 如 rand( )%5 就产生0-4中的一个数
SetConsoleTitle( )函数在<windows.h>里, srand( )函数与rand( )函数要配合用,
就是同时要用,在<stdlib.h>里。如果 rand( )%10+1 就产生1-10之中的一个数。
Sleep(300); //延时300毫秒(就是程序暂停300毫秒后继续运行)
system("cls"); //清屏(把窗口里的内容全部清除,光标定于(0,0)位置处)
这两个函数都在<windows.h>里。开头4个自编函数 编写如下:
void gtxy (int x, int y) //控制光标位置的函数
{ COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition ( GetStdHandle (STD_OUTPUT_HANDLE), pos );
}
void Color (short ForeColor= 7, short BackGroundColor= 0) //设定颜色的函数
{ HANDLE hl = GetStdHandle ( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute ( hl, ForeColor + BackGroundColor * 0x10 );
}
声明时原型可写 void Color (short x, short y);
void yinc (int x,int y) //隐藏光标的函数
{ CONSOLE_CURSOR_INFO gb={ x , y }; //gb代表光标
SetConsoleCursorInfo ( GetStdHandle(STD_OUTPUT_HANDLE), &gb );
}
void kou(int w,int h) //设置窗口大小的函数
{HANDLE hl=GetStdHandle ( STD_OUTPUT_HANDLE ) ;
COORD size={ w , h };
SetConsoleScreenBufferSize( hl , size );
SMALL_RECT rc={ 0, 0, w, h };
SetConsoleWindowInfo( hl, 1, &rc );
}
最后这个函数,参数w是宽h是高。里边5行中第一行定义了句柄型变量hl,并给它赋值。
第二行定义了坐标型结构体变量size,它的取值决定了缓冲区的大小。第三行就是使用
size的值设置好缓冲区大小。第四行定义了变量rc,它的值决定当前窗口显示的位置与
大小(不得超过缓冲区的大小)。前两个0,0是从缓冲区左上角0列0行位置处开始,后两
个参数可以小于w和h.比如 rc={0,0,w-10,h-5}; 最后一行使用rc的值设置好窗口,中间
那个参数要为" 1 "或写“ true ”才有效。
现在都不用tc了那么网上的c语言代码,graphics。h的库不能用了
只能用c++的gdi了
简单点的游戏就贪吃蛇了,没几行,至于算法,要么用c++的画图函数,要么直接调用api,要么printf加上一些二维数组实现的算法
5、手机pos机怎么安装下载
为你带来支付通pos机手机客户端下载,将支付通pos机下载安装到手机即可体验便捷的无线收款功能,还能体验一站式金融服务。软件介绍
1、支付通pos机app页面全新改版,以悦动的橙色为主色调,在满足商户收款需求的同时、又重磅推出金融理财服务,带给商户不一样的收款体验。
2、支付通pos金融理财产品是由金融、法律和电子商务等领域专业人才团队量身打造并经国有担保公司担保,为支付通pos商户提供更高收益、更高安全、更高灵活的理财产品
3、支付通pos为商户提供收款服务的同时,解决商户在经营时不便办理银行卡转账,信用卡还款、手机充值等业务的燃眉之急。同时也为商户店面无成本投入下增加客流量,提高店面销售额。
软件特色
无线蓝牙
借助蓝牙技术实现无线收款,无线连接智能升级,智能交易管理。
增值服务
手机充值、信用卡还款、卡卡转账、电子钱包充值、水电煤缴费、ETC速通卡充值。
互联网金融
托管资金,投资理财,保证收益;国有企业担保产品。
小微“贷”
解决小微商户资金周转难题,使其资金流转效率有效提高。 手机下载软件方法有很多,为您提供以下几种方式,请您参考:
1.通过手机中“三星应用商店”或“Galaxy特色订制”搜索需要的软件并下载安装。
2.通过手机浏览器搜索需要的软件下载安装(若是自带的浏览器,下载的安装包保存在我的文件-Download文件夹中)。
3.通过第三方助手类软件下载安装需要的程序。
4.通过电脑下载APK格式的安装包,然后传输到手机中安装。 先下载和POS机相匹配的手机软件然后连接POS机设置就可以用了,很简单。手续低的pos,我清楚哦 这事5100没必要找人,现在63都是自己就164可以操作,数是徵

转载请带上网址:http://www.pos-diy.com/posjifour/253211.html
- 上一篇:苏州怎样申请个人pos机刷卡器
- 下一篇:poss机低压保护是什么意思