⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chinese.cpp

📁 课题研究用的直线型一级倒立摆的源程序
💻 CPP
字号:
#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>

long pcode[200];
unsigned char sino_chr[200][32];
int pcd;

void ReadLibrary()             //调入显示汉字库
{
	FILE *fp;
	fp = fopen("pend.fnt","rb");
	if (!fp) return;
	fread(pcode, sizeof(pcode), 1, fp);
	fread(sino_chr, sizeof(sino_chr), 1, fp);
	fclose(fp);
}

void SaveLibrary()             //保存显示汉字库
{
	FILE *fp;
	fp = fopen("pend.fnt", "wb");
	fwrite(pcode, sizeof(pcode), 1, fp);
	fwrite(sino_chr, sizeof(sino_chr), 1, fp);
	fclose(fp);
}

int EnQuiry(long p)
{
	int i;
	long pp;
	for (i=0; ; ++i)
	{
		pp = pcode[i];
		if (pp == -1L)
		{
			pcd = i;
			return (-1);
		}
		if (pp == p)
			return (i);
	}
}
//程序界面上显示字体函数
void WriteHz(int x, int y, float fx, float fy, int dt, int cr, unsigned char *str)    
{
	FILE *fp;
	unsigned char dot;
	long addr;
	float a1, a2, a3, a4;
	int i, j, k, len, n, qi, wei;
	int check;
	unsigned char chr[32];
	len = strlen(str) / 2;
	setfillstyle(1, cr);
	for (n=0; n<len; n++)
	{
		if (str[n+n] < 0xa0)
		{
			qi =3;
			wei = str[n+n] - 32;
			goto L;
		}

		if (str[n+n] == 32)
			continue;

		qi = str[n+n]-0xa0;
		wei = str[n+n+1]-0xa0;

	L:	addr = (long)((qi-1) * 94 + wei - 1) * 32;
		check = EnQuiry(addr);
		if (check == -1)
		{
			fp = fopen("hzk16", "rb");
			if (!fp)
			{
				gotoxy(10, 10);
				printf("Can't open hzk16!\n");
				exit(1);
			}

			fseek(fp, addr, 0);
			fread(chr, 1, 32, fp);
			pcode[pcd] = addr;
			for (i=0; i<33; i++)
				sino_chr[pcd][i] = chr[i];

			fclose(fp);

		}

		else
			for (i=0; i<33; i++)
				chr[i] = sino_chr[check][i];

		for (i=0; i<16; i++)
		{
			for (k=0; k<=1; k++)
			{
				dot = chr[i+i+k];
				for (j=0; j<8; j++)
				{
					if ((dot>>j&1) != 0)
					{
						a1 = x + n*dt + (n * 16 + 8 * k - j + 7) * fx;
						a2 = y + i * fy;
						a3 = a1 + fx - 0.3;
						a4 = a2 + fy - 0.3;
						bar ((int)a1, (int)a2, (int)a3, (int)a4);
					}
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -