成功把C代码转换成C#代码的送出120分!!

csky 2002-04-15 11:21:44
#include <stdlib.h>
#include <stdio.h>
#include <graphics.h>
#include <string.h>

#define HZK16 "hzk16"

int test(unsigned int a,int k)
{
a<<=(k-1);
if(a&0x80)
return (1);
else
return (0);
}


void hz16(int X,int Y,char *zw,int c)
{ int n=0;
while(n!=strlen(zw)){ register int i,j;
register int xx=0;
register int yy=0;
FILE *fp;char *wm;long num;
fp=fopen(HZK16,"rb++");
if(fp==NULL){/*打开hzk16字库错误*/exit(0);}
if((zw[n]&0x80)==0)
{
num=188+zw[n]-33;
fseek(fp,(32)*num,0);
fread(wm,32,1,fp);
fclose(fp);
for(i=0;i<32;i++)
{for(j=1;j<=8;j++)
if(test(wm[i],j)==0)
xx++;
else{putpixel((xx)+X,Y+yy,c);xx++;}
if((i+1)%2==0){xx=0;yy++;}
}X=X+16;n=n+1;
}else{
zw[n]=zw[n]&0x7f;
zw[n+1]=zw[n+1]&0x7f;
zw[n]=zw[n]-0x20;
zw[n+1]=zw[n+1]-0x20;
num=(zw[n]-1)*94+(zw[n+1]-1);
fseek(fp,(32)*num,0);
fread(wm,32,1,fp);
fclose(fp);
for(i=0;i<32;i++)
{for(j=1;j<=8;j++)
if(test(wm[i],j)==0)
xx++;
else{putpixel((xx)+X,Y+yy,c);xx++;}
if((i+1)%2==0){xx=0;yy++;}
}X=X+16;n=n+2;
}}
}

这段代码怎么变成C#

我变了一些,不过很多错误。。

static public void DrawString(string s, Font font, Brush brush, int x,int y, Graphics g)
{
int n = 0;
while (s.Length != 0)
{
Pen p = new Pen(brush, 1);
int i, j;
int xx = 0;
int yy = 0;
FileStream fs = File.OpenRead("HZK16");
char[] zw = s.ToCharArray(0, s.Length);
byte[] wm = null;
long num;
if ((zw[n] & 0x80) == 0)
{
num=188 + zw[n] - 33;
fs.Seek((32) * num, 0);
fs.Read(wm, 32, 1);
fs.Close();

for(i=0;i<32;i++)
{
for(j=1;j<=8;j++)
{
if(test(wm[i],j))
{
xx++;
}
else
{
g.DrawLine(p, new Point(xx + x, yy + y), new Point(xx + x, yy + y));
//putpixel((xx)+X,Y+yy,c);
xx++;
}
} //end of for

if((i + 1) % 2 == 0)
{
xx=0;
yy++;
}
} // end of for

x = x + 16;
n = n + 1;
}
else
{
zw[n] = zw[n] & 0x7f;
zw[n+1] = zw[n+1] & 0x7f;
zw[n] = zw[n] - 0x20;
zw[n+1] = zw[n+1] - 0x20;
num = (zw[n] - 1) * 94 + (zw[n+1] - 1);
fs.Seek(32 * num, 0);
fs.Read(wm, 32, 1);
for(i=0;i<32;i++)
{
for(j=1;j<=8;j++)
{
if(test(wm[i],j)==0)
{
xx++;
}
else
{
g.DrawCurve(p, new Point(xx + x, yy + y));
//putpixel((xx)+X,Y+yy,c);
xx++;
}
}

if ((i+1) % 2 == 0)
{
xx=0;
yy++;
}
}

X=X+16;
n=n+2;
}

}

} //end of method DrawString

static public bool test(int a,int k)
{
a << =(k-1);
if (a & 0x80)
return true;
else
return false;
}

不知道正确应该怎么改
...全文
60 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
csky 2002-04-16
  • 打赏
  • 举报
回复
up
csky 2002-04-16
  • 打赏
  • 举报
回复
没有人在吗?
csky 2002-04-15
  • 打赏
  • 举报
回复
就是做点阵打印咯。
zfyvc 2002-04-15
  • 打赏
  • 举报
回复
我想帮你呀,可惜<<操作符实在搞不清,好象和c不一样。
先帮忙给个解释先,.
CForce 2002-04-15
  • 打赏
  • 举报
回复
直接说想做什么吧,可以重写比改更舒服。
csky 2002-04-15
  • 打赏
  • 举报
回复
没有人吗
csky 2002-04-15
  • 打赏
  • 举报
回复
怎么搞啊
76ers 2002-04-15
  • 打赏
  • 举报
回复
faint!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
一个很强大的工具, 能将c#代码片段、文件甚至工程直接转换成java代码,并能彻底解决外部引用的DLL问题,最强的是支持c#工程的直接转换,生成的Java代码质量也很不错。软件已破解,去除了未注册版最多只能转换1000行的限制,亲测可用!压缩包内含帮助文档,不过由于软件的使用很简单,帮助文档基本可以忽略。(小提示:如无法运行,请确认是否安装了.NET framework) 下面是一些英文介绍: C# to Java Converter features include: 1. Folder conversion: Entire folders of C# code files are converted to Java code files.(文件夹转换) 2. Code snippet and file conversion: Our snippet conversion accuracy is outstanding and does not require you to insert entire methods or classes. Heuristics are used to convert code fragments wit h missing declarations. (代码片段和文件转换) 3. Full support for the latest .NET code syntax: Generics and other newer C# features are converted where possible to the Java equivalent.(全面支持最新版的.NET语法) 4. Conversion options: You can specify numerous conversion options via our Options dialog. Code formatting options, custom type & member replacements, custom string replacements, and miscellaneous options. (可以指定转换规则) 5. File comparison feature: After converting a project or folder, you can compare original and converted files side-by-side. Comparing converted code to original code.(原代码与转换后代码的比较) 6. Running from the command line: C# to Java Converter can be launched directly for a specific project, folder, or file conversion from the command line. Command line.(命令行执行) 其他一些特点: 1. Converts all versions of C# code (2002, 2003, 2005, 2008, and 2010) (可以转换所有版本的C#代码) 2. Evaluates all referenced assemblies and .NET projects in order to resolve external references more completely.(能彻底解决外部引用的dll类库) 3. Converts C# ref parameters using Java generics 4. Superb conversions of all types of arrays 5. Handles the numerous coding alternatives and ambiguities of C# code 6. Flawless conversion of all aspects of inheritance and interfaces 7. Allows custom replacement of strings in the final converted code 8. Accurate even with poorly formatted C# code

111,095

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧