zoukankan      html  css  js  c++  java
  • 一个取字模的程序

    需要字模文件: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 }
  • 相关阅读:
    mongodb
    python中读取文件的read、readline、readlines方法区别
    uva 129 Krypton Factor
    hdu 4734
    hdu 5182 PM2.5
    hdu 5179 beautiful number
    hdu 5178 pairs
    hdu 5176 The Experience of Love
    hdu 5175 Misaki's Kiss again
    hdu 5174 Ferries Wheel
  • 原文地址:https://www.cnblogs.com/doodle777/p/3160012.html
Copyright © 2011-2022 走看看