您的位置:

移动c语言代码,编程移动代码

本文目录一览:

C语言中怎么用键盘控制界面的物体移动?

这里有个用C语言控制屏幕上小飞机运动的代码,供参考:\x0d\x0a#include\x0d\x0a#include\x0d\x0a#include\x0d\x0a#include"stdio.h"\x0d\x0a#include \x0d\x0a#define N 35\x0d\x0aint scr[22][N]={0},pl=9,width=24,speed=3,density=30;\x0d\x0aint score=0,death=0;\x0d\x0avoid print(int a[][N])\x0d\x0a{\x0d\x0a system("cls");\x0d\x0a int i,j;\x0d\x0a for(i=0;i=0;i--)\x0d\x0a for(j=0;j"); \x0d\x0a switch(getchar())\x0d\x0a { \x0d\x0a case'1':width=34;break;\x0d\x0a case'2':width=24;;break; \x0d\x0a default:printf("\n错误,请重新选择...\n"); \x0d\x0a sw=1; \x0d\x0a }\x0d\x0a }while(sw);\x0d\x0a do\x0d\x0a { \x0d\x0a sw=0; \x0d\x0a printf("\n请选择敌机密度:1.大2.中3.小"); \x0d\x0a switch(getchar())\x0d\x0a { \x0d\x0a case'0':density=10;break;\x0d\x0a case'1':density=20;break;\x0d\x0a case'2':density=30;break;\x0d\x0a case'3':density=40;break; \x0d\x0a default:printf("\n错误,请重新选择...\n"); \x0d\x0a sw=1;\x0d\x0a } \x0d\x0a }while(sw);\x0d\x0a do\x0d\x0a { \x0d\x0a sw=0; \x0d\x0a printf("\n敌机的飞行速度:1.快2.中3.慢");\x0d\x0a switch(getchar())\x0d\x0a { \x0d\x0a case'1':speed=2;break;\x0d\x0a case'2':speed=3;break;\x0d\x0a case'3':speed=4;break; \x0d\x0a default:printf("\n错误,请重新选择...\n"); \x0d\x0a sw=1;\x0d\x0a } \x0d\x0a }while(sw); \x0d\x0a for(i=0;i0)\x0d\x0a scr[21][pl]=0,scr[21][--pl]=1;break;\x0d\x0a case'd':\x0d\x0a case'D':if(pl

回答于 2022-12-11

用C语言编译一个简单的物体移动程序

#includereg52.h

sbit ADDR0 = P1^0;

sbit ADDR1 = P1^1;

sbit ADDR2 = P1^2;

sbit ADDR3 = P1^3;

sbit ENLED = P1^4;

unsigned char code LedChar[]={

0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,

0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E

};

unsigned char LedBuff[7]={

0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF

};

unsigned char code image[30][8]={

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, //动画帧1

{0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F}, //动画帧2

{0xFF,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F}, //动画帧3

{0xFF,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F}, //动画帧4

{0xFF,0x0F,0x9F,0x9F,0x9F,0x9F,0x9F,0x0F}, //动画帧5

{0xFF,0x87,0xCF,0xCF,0xCF,0xCF,0xCF,0x87}, //动画帧6

{0xFF,0xC3,0xE7,0xE7,0xE7,0xE7,0xE7,0xC3}, //动画帧7

{0xFF,0xE1,0x73,0x73,0x73,0xF3,0xF3,0xE1}, //动画帧8

{0xFF,0x70,0x39,0x39,0x39,0x79,0xF9,0xF0}, //动画帧9

{0xFF,0x38,0x1C,0x1C,0x1C,0x3C,0x7C,0xF8}, //动画帧10

{0xFF,0x9C,0x0E,0x0E,0x0E,0x1E,0x3E,0x7C}, //动画帧11

{0xFF,0xCE,0x07,0x07,0x07,0x0F,0x1F,0x3E}, //动画帧12

{0xFF,0x67,0x03,0x03,0x03,0x07,0x0F,0x9F}, //动画帧13

{0xFF,0x33,0x01,0x01,0x01,0x03,0x87,0xCF}, //动画帧14

{0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7}, //动画帧15

{0xFF,0xCC,0x80,0x80,0x80,0xC0,0xE1,0xF3}, //动画帧16

{0xFF,0xE6,0xC0,0xC0,0xC0,0xE0,0xF0,0xF9}, //动画帧17

{0xFF,0x73,0x60,0x60,0x60,0x70,0x78,0xFC}, //动画帧18

{0xFF,0x39,0x30,0x30,0x30,0x38,0x3C,0x7E}, //动画帧19

{0xFF,0x9C,0x98,0x98,0x98,0x9C,0x1E,0x3F}, //动画帧20

{0xFF,0xCE,0xCC,0xCC,0xCC,0xCE,0x0F,0x1F}, //动画帧21

{0xFF,0x67,0x66,0x66,0x66,0x67,0x07,0x0F}, //动画帧22

{0xFF,0x33,0x33,0x33,0x33,0x33,0x03,0x87}, //动画帧23

{0xFF,0x99,0x99,0x99,0x99,0x99,0x81,0xC3}, //动画帧24

{0xFF,0xCC,0xCC,0xCC,0xCC,0xCC,0xC0,0xE1}, //动画帧25

{0xFF,0xE6,0xE6,0xE6,0xE6,0xE6,0xE0,0xF0}, //动画帧26

{0xFF,0xF3,0xF3,0xF3,0xF3,0xF3,0xF0,0xF8}, //动画帧27

{0xFF,0xF9,0xF9,0xF9,0xF9,0xF9,0xF8,0xFC}, //动画帧28

{0xFF,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFE}, //动画帧29

{0xFF,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF} //动画帧30

};

unsigned char index=0;

void main()

{

unsigned int j = 0;

unsigned int cnt = 0;

unsigned long sec = 0;

unsigned char i = 0;

ENLED = 0;

ADDR3 = 1;

TMOD = 0x01;

TH0 = 0xFC;

TL0 = 0x67;

TR0 = 1;

while(1)

{

if(TF0 ==1)

{

TF0 = 0;

TH0 = 0xFC;

TL0 = 0x67;

cnt++;

sec=0x1e240;

switch(j)

{ case 0: LedBuff[0] = LedChar[sec%10];j++;break;

case 1:LedBuff[1] = LedChar[sec/10%10];j++;break;

case 2:LedBuff[2] = LedChar[sec/100%10];j++;break;

case 3:LedBuff[3] = LedChar[sec/1000%10];j++;break;

case 4:LedBuff[4] = LedChar[sec/10000%10];j++;break;

case 5:LedBuff[5] = LedChar[sec/100000%10] ;j=0;break;

default:break;

}

if(cnt1000)

{ i++;

cnt=0;

}

switch(i)

{

case 0: ADDR2=0; ADDR1=0; ADDR0=0; P0=LedBuff[0];break;

case 1: ADDR2=0; ADDR1=0; ADDR0=1; P0=LedBuff[1];break;

case 2: ADDR2=0; ADDR1=1; ADDR0=0; P0=LedBuff[2];break;

case 3: ADDR2=0; ADDR1=1; ADDR0=1; P0=LedBuff[3];break;

case 4: ADDR2=1; ADDR1=0; ADDR0=0; P0=LedBuff[4];break;

case 5: ADDR2=1; ADDR1=0; ADDR0=1; P0=LedBuff[5];break;

case 6: ADDR2=1; ADDR1=1; ADDR0=0; P0=0x01;break;

case 7: ADDR2=1; ADDR1=1; ADDR0=0; P0=0xFF;break;

default:break;

}

if(i8)

{

ADDR3=0;

EA=1;

ENLED=0;

TH0=0xFC;

TL0=0x67;

TR0=1;

ET0=1;

if(index=30)

{i=0;ADDR3=1;EA=0;ET0=0;index=0;}

}

}

}}

void InterruptTimer0() interrupt 1

{

static unsigned char k=0;

static unsigned char tmr=0;

TH0=0xFC;

TL0=0x67;

P0=0xFF;

switch(k)

{

case 0: ADDR2=0; ADDR1=0; ADDR0=0; k++; P0=image[index][0]; break;

case 1: ADDR2=0; ADDR1=0; ADDR0=1; k++; P0=image[index][1]; break;

case 2: ADDR2=0; ADDR1=1; ADDR0=0; k++; P0=image[index][2]; break;

case 3: ADDR2=0; ADDR1=1; ADDR0=1; k++; P0=image[index][3]; break;

case 4: ADDR2=1; ADDR1=0; ADDR0=0; k++; P0=image[index][4]; break;

case 5: ADDR2=1; ADDR1=0; ADDR0=1; k++; P0=image[index][5]; break;

case 6: ADDR2=1; ADDR1=1; ADDR0=0; k++; P0=image[index][6]; break;

case 7: ADDR2=1; ADDR1=1; ADDR0=1; k=0; P0=image[index][7]; break;

default: break;

}

tmr++;

if(tmr250)

{

tmr=0;

index++;

}

}

中国移动的单链表的c语言程序

#includestdio.h

#includestdlib.h

typedef struct LNode

{

char data;

LNode *next;

}* LNodePtr;

LNodePtr CreateList()

{

//初始化头节点

LNodePtr head = (LNodePtr)malloc(sizeof(LNode));

head-data = 0;

head-next = NULL;

LNodePtr tNode;//临时节点

char data;

while(true)

{

scanf("%c",data);

if(data == '\0' || data == '\n' || data == '\r' || data == '\t')

{

continue;

}

if(data == '!')//输入感叹号停止插入节点

{

printf("输入链表元素结束。\n");

break;

}

if(data = 'A' data = 'Z')

{

tNode = (LNodePtr)malloc(sizeof(LNode));

tNode-data = data; /* 数据域赋值 */

tNode-next = head-next;

head-next = tNode;

}

else

{

printf("输入字符需为大写字母。\n");

}

}

return head;

}

/**

加密函数,加密的方式为链接head的所有节点前移offset位,但是不支持offset比链表的节点数多

@param head 链表头节点

@param offset 节点前移的位数

*/

void EncryptList(LNodePtr head,int offset)

{

LNodePtr tNode = head-next;

int i;

for(i = 0; i offset; i++)

{

if(tNode-next != NULL)

{

tNode = tNode-next;

}

}

if(i == offset)

{

LNodePtr newHead = tNode;

LNodePtr tail = tNode;

while (tail-next != NULL)

{

tail = tail-next;

}

tail-next = head-next;

while(tNode-next != NULL)

{

if(tNode-next != newHead)

{

tNode = tNode-next;

}

else

{

tNode-next = NULL;

break;

}

}

head-next = newHead;

}

else

{

printf("不支持移动");

}

}

void ListPrint(LNodePtr head)

{

if(head-next != NULL)

{

LNodePtr tNode = head-next;

while (tNode-next != NULL)

{

printf("%c ",tNode-data);

tNode = tNode-next;

}

printf("%c",tNode-data);

}

}

int main()

{

LNodePtr list = CreateList();

printf("\n创建的链表如下:\n");

ListPrint(list);

EncryptList(list,3);

printf("\n所有节点前移了3位之后的链表如下:\n");

ListPrint(list);

printf("\n");

return 0;

}

移动c语言代码,编程移动代码

2023-01-06
移动c语言指针,c语言字符串指针移动

2023-01-08
c语言笔记讲解,c语言程序笔记

2022-11-23
c语言移位,c语言移位代替除以10

2023-01-08
c语言二维数组移动,c语言数组的移动

2022-11-25
c语言超强代码,代码大全c语言

2022-11-23
100条c语言代码,c语言编程100例

2022-12-01
c语言编长代码,c语言代码编程

2022-11-27
c语言怎么移动字符,c语言移动字符串

2023-01-07
笑脸c语言代码,c++笑脸代码

2023-01-03
c语言移位教学,c语言位移是怎么位移的

2022-12-02
c语言随笔讲解,c语言编程讲解

2022-11-27
c语言中向前移动一位相当于,C语言中左移一位

2023-01-03
基础c语言笔记,C语言笔记

2023-01-06
简易贪吃蛇c语言代码,贪吃蛇程序代码c语言

2023-01-06
c语言左移加等于号,c语言左移和右移符号

本文目录一览: 1、C语言按位左移运算规则 2、C语言中移位运算 3、C语言中+=是什么意思? 4、c++一个等于号什么意思 5、c语言 等于号怎么用 有些是==,有些是= 6、C语言中位移位运算符?

2023-12-08
c语言状态转移,c语言状态转移方程

本文目录一览: 1、C语言DP 问题。。请看图片。 这题是贪心还是DP? DP 的话 状态转移方程是什么? 请详细解答。。 2、在C语言中,什么语句是一条限定转移语句? 3、c语言五类单词的状态转换图

2023-12-08
c语言设计游戏代码,c语言2048游戏代码

2022-11-22
c语言中左位移,C语言左移位

2023-01-04
贪吃蛇c语言代码,贪吃蛇代码c++语言

2022-12-02