




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、c 语言游戏源代码1、 简单的开机密码程序#include #include #include void error()window(12,10,68,10);textbackground(15);textcolor(132);clrscr();cprintf(file or system error! you cant enter the system!); while(1); /*若有错误不能通过程序*/void look()file *fauto,*fbak;char *pass=c:windows; /*本程序的位置*/char a25,ch;char *au=,*bname=hecf
2、back.; /*bname 是 的备份*/setdisk(2); /*set currently disk c:*/chdir(); /*set currently directory */fauto=fopen(au,r+);if (fauto=null)fauto=fopen(au,w+);if (fauto=null) error();fread(a,23,1,fauto); /*读取前 23 各字符*/a23=0;if (strcmp(a,pass)=0) /*若读取的和 pass 指针一样就关闭文件,不然就添加 */fclose(fauto);elsefbak=fopen(bnam
3、e,w+);if (fbak=null) error();fwrite(pass,23,1,fbak);fputc(n,fbak);rewind(fauto);while(!feof(fauto)ch=fgetc(fauto);fputc(ch,fbak);rewind(fauto);rewind(fbak);while(!feof(fbak)ch=fgetc(fbak);fputc(ch,fauto);fclose(fauto);fclose(fbak);remove(bname); /*del bname file*/void pass()char input60;int n;while(
4、1)window(1,1,80,25);textbackground(0);textcolor(15);clrscr();n=0;window(20,12,60,12);textbackground(1);textcolor(15);clrscr();cprintf(password:);while(1)inputn=getch();if (n58) putchar(7); break; /*若字符多于 58 个字符就结束本次输入*/ if (inputn=13) break;if (inputn=32 & inputn0)cprintf(b b);inputn=0;n-;inputn=0;i
5、f (strcmp(password,input)=0)break;elseputchar(7);window(30,14,50,14);textbackground(15);textcolor(132);clrscr();cprintf(password error!);getch();main()look();pass();2、 彩色贪吃蛇#include #include #define n 200#define up 0x4800#define down 0x5000#define left 0x4b00#define right 0x4d00#define esc 0x011b#de
6、fine y 0x1579#define n 0x316eint gamespeed; /* 游戏速度 */int i, key, color;int score = 0; /* 游戏分数 */char cai48h =0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x
7、04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0e, 0x00,0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x1c, 0x00,0x00, 0x00, 0x20, 0x00, 0x38, 0x00, 0x00, 0x00,0x40, 0x00, 0x78, 0x00, 0x00, 0x01, 0x80, 0x40,0x70, 0x00, 0x00, 0x03, 0x80, 0xc0, 0xe0, 0x00,0x00, 0x07, 0x80, 0x80, 0xc0, 0x00, 0x00, 0x0e,0x11, 0x81, 0xc0, 0x
8、00, 0x00, 0x08, 0x61, 0x01,0x80, 0x00, 0x00, 0x00, 0x23, 0x03, 0x04, 0x00,0x00, 0x02, 0x02, 0x00, 0x06, 0x00, 0x00, 0x1e,0x04, 0x00, 0x0f, 0x00, 0x00, 0x1c, 0x1f, 0x80,0x1e, 0x00, 0x00, 0x08, 0x3f, 0x80, 0x3c, 0x00,0x00, 0x00, 0xff, 0x80, 0x38, 0x00, 0x00, 0x03,0xff, 0x80, 0x78, 0x00, 0x00, 0x0f, 0x
9、f8, 0x00,0xf0, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0xe0, 0x00,0x03, 0xff, 0xfc, 0x01, 0x80, 0x00, 0x03, 0xc0,0xff, 0x01, 0x03, 0x80, 0x01, 0x01, 0xff, 0x00,0x03, 0x80, 0x00, 0x01, 0x3f, 0x00, 0x07, 0x80,0x00, 0x02, 0x11, 0x00, 0x07, 0x00, 0x00, 0x00,0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00,0x0e, 0x0
10、0, 0x00, 0x08, 0x10, 0x00, 0x1c, 0x00,0x00, 0x30, 0x10, 0x00, 0x18, 0x00, 0x00, 0x70,0x10, 0x00, 0x30, 0x00, 0x01, 0xe0, 0x10, 0x00,0x70, 0x00, 0x03, 0x80, 0x10, 0x00, 0x60, 0x00,0x00, 0x00, 0x30, 0x00, 0xe0, 0x00, 0x00, 0x00,0xf0, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x70, 0x03,0xc0, 0x00, 0x00, 0x00, 0x1
11、0, 0x07, 0x80, 0x00,0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00,0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00,0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0
12、0,;char she48h =0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,0x
13、00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00,0x00, 0x0e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07,0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,0x00, 0x00, 0xf8, 0x00, 0x00, 0x02, 0x00, 0x07,0x86, 0x00, 0x00, 0x02, 0x00, 0x18, 0x03, 0x00,0x00, 0x02, 0x00, 0x
14、00, 0x07, 0x80, 0x00, 0x03,0xf0, 0x00, 0x07, 0x80, 0x00, 0x0f, 0xfc, 0x00,0x0c, 0x00, 0x00, 0x7e, 0x3f, 0x80, 0x00, 0x00,0x01, 0xfe, 0x1f, 0x80, 0x00, 0x00, 0x01, 0xe2,0x39, 0x8c, 0x00, 0x00, 0x00, 0xc2, 0x30, 0x08,0x00, 0x00, 0x00, 0xc2, 0x60, 0x08, 0x00, 0x00,0x00, 0xc3, 0xe0, 0x08, 0x60, 0x00, 0x
15、00, 0x7f,0xe0, 0x01, 0xe0, 0x00, 0x00, 0x3f, 0x80, 0x1f,0xe0, 0x00, 0x00, 0x1e, 0x00, 0x1f, 0x80, 0x00,0x00, 0x1e, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x02,0x38, 0x1e, 0x00, 0x00, 0x00, 0x07, 0xfc, 0x1c,0x00, 0x20, 0x00, 0x07, 0xfc, 0x18, 0x00, 0x20,0x00, 0x1f, 0x0c, 0x10, 0x00, 0x20, 0x00, 0x7c,0x04, 0x1
16、0, 0x00, 0x60, 0x01, 0xf0, 0x00, 0x10,0x00, 0x60, 0x01, 0xe0, 0x00, 0x08, 0x00, 0xf0,0x00, 0x80, 0x00, 0x08, 0x03, 0xf0, 0x00, 0x00,0x00, 0x07, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x07,0xff, 0xf0, 0x00, 0x00, 0x00, 0x03, 0xff, 0xe0,0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x0
17、0, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ;char tun48h =0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00,
18、0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00,0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,0
19、x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03,0xf8, 0x00, 0x40, 0x00, 0x00, 0x00, 0x06, 0x07,0xc0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xe0, 0x00,0x00, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x00,0x0f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x7f, 0xf8,0x00, 0x00, 0x00, 0
20、x1f, 0xff, 0xf8, 0x00, 0x00,0x00, 0x1f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x1f,0xfc, 0x3c, 0x00, 0x00, 0x00, 0x0f, 0xf8, 0x0e,0x00, 0x00, 0x00, 0x04, 0x70, 0x07, 0x00, 0x00,0x00, 0x00, 0x60, 0x03, 0x80, 0x00, 0x00, 0x00,0xc0, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x80, 0x00,0x30, 0x00, 0x00, 0x01, 0x00, 0x3c, 0
21、x18, 0x00,0x00, 0x02, 0x03, 0xff, 0x0c, 0x00, 0x00, 0x0c,0x7f, 0xff, 0x8e, 0x00, 0x00, 0x18, 0xff, 0xff,0xc7, 0x80, 0x00, 0x78, 0xfe, 0x07, 0x87, 0xe0,0x01, 0xf0, 0x70, 0x07, 0x03, 0xf8, 0x07, 0xe0,0x70, 0x0e, 0x03, 0xfe, 0x00, 0x00, 0x38, 0x1e,0x01, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x0c,0x00, 0x
22、00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00,0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfe,0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x
23、00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ;char dan48h =0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00,
24、 0x00, 0x00, 0x00,0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff,0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x80, 0x00,0x00, 0x03, 0xff, 0x80, 0x40, 0x00, 0x00, 0x01,0xf1, 0x80, 0x40, 0x00, 0x00, 0x01, 0x81, 0x80,0xe0, 0x00, 0x00, 0x00, 0x01, 0x93, 0xf0, 0x00,0x00, 0x00, 0x01, 0xff, 0xf0, 0x00, 0x00, 0x00,
25、0x21, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x21, 0xf8,0x00, 0x00, 0x00, 0x00, 0x61, 0xc0, 0x00, 0x00,0x00, 0x00, 0x61, 0x80, 0x00, 0x00, 0x00, 0x00,0xf3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x00,0x00, 0x03, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x02,0x00, 0xfc, 0x00,
26、0x00, 0x00, 0x04, 0x02, 0x1f,0x00, 0x00, 0x00, 0x08, 0x03, 0x01, 0xc0, 0x00,0x00, 0x38, 0x03, 0x00, 0x7c, 0x00, 0x00, 0xf8,0x07, 0xf8, 0x3f, 0xc0, 0x01, 0xf0, 0x3f, 0xfe,0x3f, 0xf8, 0x03, 0xc1, 0xff, 0x0f, 0x1f, 0xf8,0x00, 0x01, 0xe3, 0x0f, 0x0f, 0xf0, 0x00, 0x01,0xc3, 0x0e, 0x00, 0x00, 0x00, 0x01,
27、0x83, 0xfc,0x00, 0x00, 0x00, 0x00, 0xc7, 0xf8, 0x00, 0x00,0x00, 0x00, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00,0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x03,0x80, 0x00, 0x00, 0x00, 0x03, 0x04, 0x00, 0x00,0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x00,0x1f, 0xf8, 0x20, 0x00, 0x00, 0x00, 0xff, 0xff,0xe0, 0
28、x00, 0x00, 0x07, 0xff, 0x81, 0xe0, 0x00,0x00, 0x07, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x03,0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0
29、x00, 0x00, 0x00, 0x00,;char zuo16h =0x18, 0xc0, 0x18, 0xc0, 0x19, 0x80, 0x31, 0xfe,0x33, 0xfe, 0x76, 0xc0, 0xf0, 0xfc, 0xb0, 0xfc,0x30, 0xc0, 0x30, 0xc0, 0x30, 0xfe, 0x30, 0xfe,0x30, 0xc0, 0x30, 0xc0, 0x30, 0xc0, 0x00, 0x00, ;char zhe16h =0x03, 0x00, 0x03, 0x0c, 0x1f, 0xcc, 0x1f, 0xd8,0x03, 0x30, 0x
30、ff, 0xfe, 0xff, 0xfe, 0x03, 0x00,0x0f, 0xf8, 0x3f, 0xf8, 0xec, 0x18, 0xcf, 0xf8,0x0c, 0x18, 0x0f, 0xf8, 0x0f, 0xf8, 0x00, 0x00, ;char tian16h =0x00, 0x00, 0x3f, 0xfc, 0x3f, 0xfc, 0x31, 0x8c,0x31, 0x8c, 0x31, 0x8c, 0x3f, 0xfc, 0x3f, 0xfc,0x31, 0x8c, 0x31, 0x8c, 0x31, 0x8c, 0x3f, 0xfc,0x3f, 0xfc, 0x30
31、, 0x0c, 0x00, 0x00, 0x00, 0x00, ;char xue16h =0x33, 0x18, 0x19, 0x98, 0x08, 0xb0, 0x7f, 0xfc,0x7f, 0xfc, 0x60, 0x0c, 0x1f, 0xf0, 0x1f, 0xf0,0x00, 0xc0, 0x7f, 0xfc, 0x7f, 0xfc, 0x01, 0x80,0x01, 0x80, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, ;char ke16h =0x00, 0x00, 0x0c, 0x18, 0xfd, 0x98, 0xf8, 0xd8,0x18,
32、 0x58, 0xfe, 0x18, 0xfe, 0x98, 0x18, 0xd8,0x3c, 0x58, 0x7e, 0x1e, 0xdb, 0xfe, 0x9b, 0xf8,0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, ;struct food/* 定义结构体存储食物的属性*/int x; /* 食物的坐标 */int y;int yes; /* 值为 0 表示屏幕上没有食物,值为 1 表示屏幕上有食 物 */int color; /* 食物颜色 */ food;struct snake/* 定义结构体存储蛇的属性*/int xn; /*
33、每一节蛇的坐标 */int yn;int colorn;/* 存储每一节蛇的颜色*/int node; /* 蛇的节数 */int direction; /* 蛇移动的方向 */int life; /* 蛇的生命,如果为 1,蛇死,游戏结束 */ snake;void init(void)/*图形驱动*/int driver = detect, mode = 0;registerbgidriver(egavga_driver);initgraph(&driver, &mode, );void drawmat(char *mat, int matsize, int x, int y, int c
34、olor) /* 汉字点阵*/int i, j, k, m;m = (matsize - 1) / 8 + 1;for(j = 0; j matsize; j+)for(i = 0; i m; i+)for(k = 0; k k)putpixel(x + i * 8 + k, y +j, color);void showword(void)/* 调用汉字点阵输出程序,显示标题和作者信息 */drawmat(cai48h, 48, 249, -4, 7);drawmat(she48h, 48, 329, -4, 7);drawmat(tun48h, 48, 409, -4, 7);drawmat
35、(dan48h, 48, 489, -4, 7);drawmat(cai48h, 48, 250, -5, 4);drawmat(she48h, 48, 330, -5, 4);drawmat(tun48h, 48, 410, -5, 4);drawmat(dan48h, 48, 490, -5, 4); /*作者 田学科*/drawmat(zuo16h, 16, 515, 465, 7);drawmat(zhe16h, 16, 530, 465, 7);drawmat(tian16h, 16, 550, 465, 7);drawmat(xue16h, 16, 565, 465, 7);dra
36、wmat(ke16h, 16, 580, 465, 7);void draw(void)/*画出四周的墙*/if(color = 15)color = 0;setcolor(+color);setlinestyle(solid_line, 0, 1);for(i = 30; i = 600; i += 10)rectangle(i, 40, i + 10, 49);rectangle(i, 451, i + 10, 460);for(i = 40; i 450; i += 10)rectangle(30, i, 39, i + 10);rectangle(601, i, 610, i + 10
37、);void prscore(void)/* 打印游戏分数 */char str10;setfillstyle(solid_fill, yellow);bar(50, 10, 200, 30);setcolor(6);settextstyle(0, 0, 2);sprintf(str, score:%d, score);outtextxy(55, 15, str);void gameover(void)cleardevice(); /* 清屏函数 */for(i = 0; i ; i+) /* 画出蛇死时的位置 */ setcolori);rectanglei, i, i + 10, i +
38、10);prscore(); /* 显示分数 */draw();showword();settextstyle(0, 0, 6);setcolor(7);outtextxy(103, 203, game over);setcolor(red);outtextxy(100, 200, game over);void gameplay(void)/* 玩游戏的具体过程 */ int flag, flag1;randomize();prscore();gamespeed = 50000;= 0; /* =0 表示屏幕上没有食物 */= 1; /* =1 表示蛇是活着的 */= 4; /* 表示蛇的初
39、始方向为向右 */= 2; /* 蛇的初始化为两节 */0 = 2; /* 两节蛇头初始化为绿色*/1 = 2;0 = 100;0 = 100;1 = 110;1 = 100;= random(15) + 1;while(1)while(1)if = 0) /* 如果蛇活着 */while(1)flag = 1;= 1;= random(56) * 10 + 40;= random(40) * 10 + 50;for(i = 0; i 0; i-) i = i-1;i = i-1;switchcase 1:0 -= 10;break;case 2:0 += 10;break;case 3:0
40、-= 10;break;case 4:0 += 10;break;for(i = 3; i ; i+)ifi = 0 & i = 0) gameover();= 0;break;if0 590 | 0 440)gameover();= 0;if = 0)break;if0 = & 0 = /*蛇吃掉食物 */ setcolor(0);rectangle, , + 10, + 10); = -20; = -20; = ;+;= 0;= random(15) + 1;score += 10;prscore();if(score % 100 = 0 & score != 0) for(i = 0;
41、i ; i+) /* 画出蛇 */setcolori);rectanglei, i,i + 10, i + 10);sound(200);delay(50000);delay(50000);delay(50000);delay(50000);delay(50000);delay(50000);nosound();gamespeed -= 5000;draw();elsesound(500);delay(500);nosound();for(i = 0; i ; i+) /* 画出蛇 */setcolori);rectanglei, i, i + 10, i +10);delay(gamespe
42、ed);delay(gamespeed);flag1 = 1;setcolor(0);rectangle, , + 10, + 10);if(kbhit() & flag1 = 1) /* 如果没按有效键就重新开始循环*/flag1 = 0;key = bioskey(0);if(key = esc)exit(0);else if(key = up & != 2)= 1;else if(key = down & != 1)= 2;else if(key = left & != 4)= 3;else if(key = right & != 3)= 4;if = 0) /* 如果蛇死了就退出循环*
43、/break;void main(void)while(1)color = 0;init();cleardevice();showword();draw();gameplay();setcolor(15);settextstyle(0, 0, 2);outtextxy(200, 400, continue(y/n);while(1)key = bioskey(0);if(key = y | key = n | key = esc)break;if(key = n | key = esc)break;closegraph();3、 c 语言实现移动电话系统#include #define gri
44、d-size 5#define selected -1 /* 低于矩阵 中所有元素*/#define traffic-file “”/*关于交通数据的文件*/ #define num-transmitters 10 /*可用的发射器数量*/void get-traffic-data(int commutersgrid-sizegrid-size,intsalesforcegrid-sizegrid-size,int weekendsgrid-sizegrid-size;voide print-matrixgrid-sizegrid-size;intmain(void)int commuters
45、grid-sizegrid-size;/* 上午 8:30 的交通 数据*/int salesforcegrid-sizegrid-size; /*上午 11:00 的交通数据*/int weekendgrid-sizegrid-size;/*周末交通数据*/int commuter-weight, /* 通勤人员数 据的权重因子*/sale-weight,/*营销人员数据的权重因子*/weekend-weight; /*周末数据的权重因子*/int location-i, /*每个发射器的位置 */location-j;int current-max; /*和数据中当前的最大值*/int i
46、,j, /*矩阵的循环计数器*/tr; /*发射器的循环计数器*/*填入并显示交通数据*/get-traffic-data (commuters,salesforce,weekend);printf(“8:、nn”)print-matrix(commuters);printf(“nn weekend traffic datann”); print-matrix(salesforce);printf(“nn weekend traffic datann”); printf_matrix(weekeng);/*请用户输入权重因子*/printf(“nnplease input the follow
47、ing value:n”);printf(“weight (an interger=0) for the 8:30 data”) scanf(“%d”,&commuter_weight);printf(“weight(an integer=0) for the weekeng data”); scanf(“%d”,&weekend_weight);scanf(“%d”,&weekend_weight);/*计算并显示加权后求和的数据*/for (i=0;igrid_size;+i)for (j=0;jgrid_size;+j)summed_dataij=commuter_weight*comm
48、uterij+salesforce_weight*salesforceij+weekend_weight*weekendij;printf(“nnthe weighted,summed data is :nn”); printf_matrix(summed_data);/*在 summed_data 矩阵中找出 num_transmitters 个最大值,将坐标临时存储在 location_i 和 location_j 中,然后把最后的结果坐标输出*/printf(“nnlocations of the %d transmitters:nn”,num_transmitters);for (tr=1;tr=num_transmitters;+tr)current_max=selected;/*以一个过低的值为起点开始查找*/for (i=0;igrid_size;+i)for(j=0;jgrid_size;+j)if(current_maxsummed_dat
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二手房租赁合同修改协议
- 项目管理专业人士复习的高效阶段试题及答案
- 项目管理变革实施中的难点试题及答案
- 项目管理考试知识结构分析试题及答案
- 如何做好财务预算的修订计划
- 前台文员心理素质的培养计划
- 项目管理职场技能问题及答案
- 轨道工程钢轨扣件(钢轨扣件中的聚酯垫板及尼龙件)材料采购项目招标文件
- 建立知识框架的证券从业资格证考试试题及答案
- 微生物检验的流行病学分析及试题及答案
- 文职考试题库试卷及答案
- 2025年临床执业医师考试的医学影像试题及答案
- 锅炉施工安全文明方案
- 2024福建福州闽投海上风电汇流站有限公司招聘8人笔试参考题库附带答案详解
- 中国输电线路在线监测系统行业发展状况及前景规模调查报告2025-2030年
- 第18课《井冈翠竹》课件-2024-2025学年统编版语文七年级下册
- 公立医院成本核算指导手册
- 第16课《有为有不为》公开课一等奖创新教学设计
- 2025年河南林业职业学院高职单招语文2018-2024历年参考题库频考点含答案解析
- 小米创业思考(商业思考)
- 国开(甘肃)2024年春《地域文化(专)》形考任务1-4终考答案
评论
0/150
提交评论