• 一个取字模的程序


    需要字模文件:ASC16 HZK16 放于上层根目录内(自己去下载。。。)
     
     
     
     
      1 /*********************************
      2  * 程序名称:doodle777 的取字模程序
      3  * 作    者:doodle777
      4  * 邮    箱:duanxu@outlook.com
      5  * 版 本 号:1.0
      6  * 完成时间:2012-08-30-PM
      7  * 说    明:需要字模文件:ASC16 HZK16 放于上层根目录内
      8  *
      9  **********************************/
     10 
     11 #include<stdio.h>
     12 #include<stdlib.h>
     13 #include<conio.h>
     14 
     15 #define ASC_16 16
     16 #define HZK_16 16
     17 #define MAXASC 8
     18 #define MAXHZK 2
     19 
     20 void PrintASCChar(char * modelchar , char * forechar , char * backchar);
     21 void PrintHZKChar(char * modelchar , char * forechar , char * backchar);
     22 
     23 void main()
     24 {
     25     int mode,number=0;
     26     char input;
     27     char ascchar[MAXASC+1]= {0}, hzkchar[2*MAXHZK+1]= {0};
     28     char * asc_forechar, * asc_backchar, * hzk_forechar, * hzk_backchar;
     29     asc_forechar = "W";
     30     asc_backchar = " ";
     31     hzk_forechar = "";
     32     hzk_backchar = "  ";
     33 
     34     do
     35     {
     36         fflush(stdin);
     37         printf("PLEASE SELECT THE MODE(1-ENGLISH, 2-CHINESE, 3-EXIT): ");
     38         mode=getchar();
     39         fflush(stdin);
     40         if('1'==mode)
     41         {
     42             printf("PLASE INPUT THE STRING YOU WANT TO SHOW (MAX WITH 8 CHARACTERS):");
     43             while((input=getchar())!='
    ')
     44                 ascchar[number++] = input;
     45             PrintASCChar(ascchar,asc_forechar,asc_backchar);
     46         }
     47         if('2'==mode)
     48         {
     49             printf("PLASE INPUT THE STRING YOU WANT TO SHOW (MAX WITH 2  CHINESE CHARACTERS):");
     50             scanf("%s",hzkchar);
     51             PrintHZKChar(hzkchar,hzk_forechar,hzk_backchar);
     52         }
     53         if('3'==mode)
     54             exit(0);
     55     }
     56     while(mode=='1'||mode=='2'||mode=='3');
     57 
     58     getch();
     59 }
     60 
     61 void PrintASCChar(char * modelchar , char * forechar , char * backchar)
     62 {
     63     int i,j,num;
     64     char code[MAXASC][ASC_16];
     65     unsigned long offset[MAXASC];
     66     FILE *fASC;
     67 
     68     if((fASC=fopen("../ASC16","r"))==NULL)
     69     {
     70         printf("FILE OPEN ERROR! PLEASE ADD FILE IN UPPER DESTINATION.");
     71         getch();
     72         exit(0);
     73     }
     74     for(num=0; num<MAXASC; num++)
     75     {
     76         offset[num] = *(modelchar+num)*ASC_16 + 1;
     77         fseek(fASC, offset[num], SEEK_SET);
     78         fread(code[num], ASC_16, 1, fASC);
     79     }
     80 
     81 //printf("character = %s, offset = %ld
    ",modelchar, offset);
     82     for(i=0; i<ASC_16; i++)
     83     {
     84         printf("    ");
     85         for(num=0; num<MAXASC; num++)
     86         {
     87             for(j=0; j<ASC_16/2; j++)
     88                 if(code[num][i]&(0x80>>j))
     89                     printf(forechar);
     90                 else printf(backchar);
     91             printf(backchar);
     92         }
     93         printf("
    ");
     94     }
     95 }
     96 
     97 
     98 void PrintHZKChar(char * modelchar , char * forechar , char * backchar)
     99 {
    100     int i,j,k,num;
    101     char code[MAXHZK][HZK_16*2];
    102     unsigned char quma[MAXHZK],weima[MAXHZK];
    103     unsigned long offset[MAXHZK];
    104     FILE *fHZK;
    105 
    106     if((fHZK=fopen("../HZK16","r"))==NULL)
    107     {
    108         printf("FILE OPEN ERROR! PLEASE ADD FILE IN UPPER DESTINATION.");
    109         getch();
    110         exit(0);
    111     }
    112     for(num=0; num<MAXHZK; num++)
    113     {
    114         quma[num]  = *(modelchar+2*num) - 0xa0;
    115         weima[num] = *(modelchar+2*num+1) - 0xa0;
    116         offset[num] = (94*(quma[num]-1)+(weima[num]-1))*(HZK_16*2);
    117         fseek(fHZK, offset[num], SEEK_SET);
    118         fread(code[num], HZK_16*2, 1, fHZK);
    119     }
    120 
    121 //printf("character = %s, quma = %d, weima = %d, offset = %ld
    ",modelchar, quma, weima, offset);
    122     for(i=0; i<HZK_16; i++)
    123     {
    124         printf("    ");
    125         for(num=0; num<MAXHZK; num++)
    126             for(k=0; k<2; k++)
    127                 for(j=0; j<HZK_16/2; j++)
    128                     if(code[num][i*2+k]&(0x80>>j))
    129                         printf(forechar);
    130                     else printf(backchar);
    131         printf(backchar);
    132         printf("
    ");
    133     }
    134 }
  • 相关阅读:
    (八)shell 计算命令
    (七)shell内建命令
    (六)shell数组深入解析
    (五)shell字符串深入解析
    输出链表的倒数第K个值
    反转链表
    调整该数组中数字的顺序,奇数在前,偶数在后
    基类与派生类的对象调用
    printf以%d形式输出浮点数的问题
    数值的整数次方
  • 原文地址:https://www.cnblogs.com/doodle777/p/3160012.html
Copyright © 2020-2023  润新知