高分悬赏急求一段源代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了高分悬赏急求一段源代码相关的知识,希望对你有一定的参考价值。

急求一段500-800行以上的源代码,要求能在VC6.0上编译成功并生成可执行程序,代码内容不限,应用程序小游戏或其他都可以时间紧迫,谢谢哥们了~~
有没可视化的程序??

参考技术A #include<iostream>
#include<fstream>
#include<conio.h>
using namespace std;

class Librarian //图书管理员类

public:
Librarian();
Librarian(int n,int j,char na[20],int w );
int getnumber();
int getjobage();
char *getname();
int getwages();
void resetjobage(int j);
void resetwages(int w);
void resetname(char na[20]);
private:
int number;
int jobage;
char name[20];
int wages;
;
Librarian::Librarian() //其函数的实现

number=0;
char b[20]="no one";
jobage=0;
strcpy(name,b);

Librarian::Librarian(int n,int j,char na[20],int w)

number=n;
jobage=j;
strcpy(name,na);
wages=w;

int Librarian::getjobage()
return jobage;
char *Librarian::getname()
return name;
int Librarian::getnumber()
return number;
int Librarian::getwages()
return wages;
void Librarian::resetjobage(int j)

jobage=j;

void Librarian::resetname(char na[20])

strcpy(name,na);


void Librarian::resetwages(int w)

wages=w;


class reader //读者类

private:
int number;
int age;
char name[20];
char borrowbook[20];
public:
reader();
reader(int c,int a,char b[20],char e[20]);
int getnumber();
int getage();
char *getname();
char * getborrowbook();
void reworkborrowbook(char a[20]);
;
reader::reader() //其函数的实现

char a[20]="没有人";
char c[20]="没有借书";
number=0;
age=0;

reader::reader(int a,int c,char d[20],char e[20])

number=a;
age=c;
strcpy(name,d);

strcpy(borrowbook,e);

int reader::getnumber()return number;
int reader::getage()return age;
char *reader::getname()return name;
char * reader::getborrowbook()return borrowbook;
void reader::reworkborrowbook(char a[20])strcpy(borrowbook,a);

struct book //图书的结构体

int num;

char name[20];
char writer[20];
;

void outbookinf() //输出所有图书信息

int i;
ifstream infile("allbook.txt",ios::in);
char line[50];
cout<<"书名"<<'\t'<<"书号"<<'\t'<<"作者"<<endl;
for(i=1;i<=10;i++)

infile.getline(line,50,'\n');
cout<<line<<endl;

infile.close();


void serchLaninf() //图书管理员信息函数

int n,i;
ifstream file("serchLaninf.txt");
if(file) file>>n; file.close();
else cout<<"没有图书管信息理员"; exit(0);
ifstream is("controlloer.txt",ios_base::binary);
if(is)

Librarian *A=new Librarian[n];
for(i=0;i<n;i++)

is.read((char *)&A[i],sizeof(A[i]));

for(i=0;i<n;i++)

cout<<"编号"<<'\t'<<"工龄"<<'\t'<<"名字"<<'\t'<<"工资"<<endl;
cout<<A[i].getnumber()<<"\t"<<A[i].getjobage()<<"\t"<<A[i].getname()<<"\t"<<A[i].getwages()<<endl;


else

cout<<"txt文件打开出错'"<<endl;

is.close();


void libary() //图书馆的总信息

system("cls");
system("color 2e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<"本校图书馆由本部图书馆及彭州校区图书馆组成,图书馆总面积达了****平方米";
cout<<" (本馆现在有***类书籍***万册,****类书籍****万册,****类书籍****万册****类书籍****万册),";
cout<<"图书馆现有工作人员***名";
cout<<"图书馆现有的现代化设备价值超过****万元………………"<<endl;


void storelibrarian() //存入新的管理员的信息

int age,n,num,wage;
char name[20];
ifstream file("serchLaninf.txt");
if(file) file>>n; file.close();
else n=0;
cout<<"已有的图书管理员个数:";
cout<<n<<endl;
cout<<"请输入新图书管理员的编号和工龄,名字和工资:";
cin>>num>>age>>name>>wage;
Librarian A(num,age,name,wage);
cout<<"编号 工龄 名字 工资 "<<endl;
cout<<A.getnumber()<<" "<<A.getjobage()<<" "<<A.getname()<<" "<<A.getwages()<<endl;
ofstream outfile("controlloer.txt",ios_base::app );
outfile.write((char *)&A,sizeof(A));
outfile.close();
n++;
ofstream tfile("serchLaninf.txt");
tfile<<n;
tfile.close();
cout<<"保存成功!";


void reLaninf() //修改图书管理员

int i,n,h,jobage,wage,j;
char name[20];
ifstream file("serchLaninf.txt");
if(file) file>>n; file.close();
else cout<<"没有图书管信息理员";
exit(0);
cout<<"已有的图书管理员个数:";
cout<<n<<endl;
Librarian *A=new Librarian[n];
ifstream is("controlloer.txt",ios_base::binary);
if(is)

for(i=0;i<n;i++)

is.read((char *)&A[i],sizeof(A[i]));

for(i=0;i<n;i++)

cout<<"编号 工龄 名字 工资"<<endl;
cout<<A[i].getnumber()<<" "<<A[i].getjobage()<<" "<<A[i].getname()<<" "<<A[i].getwages()<<endl;


else

cout<<"打开文件出错"<<endl;

is.close();
cout<<"请选择你要修改的管理员编号:";
cin>>h;
cout<<"输入新的工龄,名字,工资:";
cin>>jobage>>name>>wage;
A[h-1].resetjobage(jobage);
A[h-1].resetname(name);
A[h-1].resetwages(wage);
cout<<"该管理员修改后的名字是:"<<A[h-1].getname()<<" 工龄是:"<<A[h-1].getjobage()<<" 工资是:"<<A[h-1].getwages()<<endl;
ofstream tfile("controlloer.txt",ios_base::binary);
for(j=0;j<n;j++)

tfile.write((char *)&A[j],sizeof(A[j]));

tfile.close();


void aadbook() //新增图书

int num;char name[12];char writer[10];int n;
a:
ofstream fout("allbook.txt",ios::app);
cout<<"请录入图书信息:"<<endl;
cout<<"书名"<<'\t'<<"书号"<<'\t'<<"作者"<<endl;
cin>>name;fout<<name<<'\t';
cin>>num;fout<<num<<'\t';
cin>>writer;fout<<writer<<'\n';
fout.close();
cout<<"是否继续录入?1.是2.否"<<endl;
cin>>n;
if(n==1)
goto a;
else
void studentland();
studentland();


void delate() //删除函数
int m;
cout<<"选择操作选项:"<<endl;
cout<<" 1.删除全部信息"<<endl;
cout<<" 2.单个删除"<<endl;
cin>>m;
if(m==1)
ofstream file("allbook.txt",ios::trunc);
cout<<"全部删除完毕,按任意键返回!"<<endl;
file.close();
getch();
system("cls");
void studentland();
studentland();

char str[10][80],buf[20];
a:
int i=0,flag=100,c=0;

ifstream fin("allbook.txt");
if(!fin)
cout<<"文件打开失败!"<<endl;
getch();
system("cls");
void studentland();
studentland();

cout<<"请输入你要删除的书名:"<<endl;
cin>>buf;
strcat(buf,"\t");

while(fin.getline(str[i],80))

if(strncmp(str[i],buf,strlen(buf))==0)

flag=i;

i++;


fin.close();

if(flag==100)

cout<<"没有你所要删除的书籍!重新按1,否则0....."<<endl;
int b;
cin>>b;
if(b==1)goto a;
else c=1;

if(c==0)
ofstream fout("allbook.txt");
for(int j=0;j<i;j++)
if(j==flag)continue;
fout<<str[j]<<endl;

fout.close();
cout<<"你要删除的书籍的信息已删除,继续按1,否则按0....."<<endl;
int b;
cin>>b;
if(b==1)goto a;

cout<<"操作已经结束,按任意键返回......"<<endl;
getch();
system("cls");
void studentland();
studentland();


void searchbook() // 查找书籍

a:
ifstream fin;
int flag=0,b,length;
char str[20];
char f[200];char g[200];
fin.open("allbook.txt");
if(!fin)

cout<<"Open f1.dat error....."<<endl;
exit(1);

while(1)

cout<<"请输入书名:";
cin>>str;
strcat(str,"\t");
length=strlen(str);
cout<<"------------------------------------"<<endl;
while(fin.getline(f,199))

strcpy(g,f);
if(strncmp(str,f,length)==0)

flag=1;
break;


if(flag==1)

cout<<"所查询的书已经找到:"<<'\n';
cout<<"--------------------------------"<<endl;
cout<<"书名"<<'\t'<<"书号"<<'\t'<<"作者"<<'\t'<<endl;
cout<<g<<endl;
cout<<"--------------------------------"<<endl;
flag=0;
cout<<"要继续查询按1,否则按0:"<<endl;
cin>>b;
if(b==0)break;

else

fin.close();
cout<<"没有此书,继续按1,否则按0..."<<endl;
cin>>b;
if(b==0)break;
goto a;


fin.close();
cout<<"查询完毕,按任意键返回......"<<endl;
getch();
system("cls");
void studentland();
studentland();


void seachreader() // 查询读者信息

a:
ifstream fin;
int flag=0,b,length;
char str[20];
char f[200];char g[200];
fin.open("readernum.txt");
if(!fin)

cout<<"没有此信息文件!"<<endl;
exit(1);

while(1)

cout<<"请输入你要查找读者的名字:";
cin>>str;
strcat(str,"\t");
length=strlen(str);
cout<<"------------------------------------"<<endl;
while(fin.getline(f,199))

strcpy(g,f);
if(strncmp(str,f,length)==0)

flag=1;
break;


if(flag==1)

cout<<"所查询的读者已经找到:"<<'\n';
cout<<"--------------------------------"<<endl;
cout<<"名字"<<'\t'<<"编号"<<'\t'<<"年龄"<<'\t'<<"借书次数"<<endl;
cout<<g<<endl;
cout<<"--------------------------------"<<endl;
flag=0;
cout<<"要继续查询按1,否则按0:"<<endl;
cin>>b;
if(b==0)break;
goto a;

else

fin.close();
cout<<"没有此人,继续按1,否则按0..."<<endl;
cin>>b;
if(b==0)break;
goto a;


fin.close();
cout<<"查询完毕,按任意键返回......"<<endl;
getch();
system("cls");
void studentland();
studentland();


/*void seachreader() //查询读者的信息

int i,b,h=0;
char a[20];
ifstream file("readernum.txt");
if(file) file>>b; file.close();
else cout<<"没有文件";
cout<<"已有的读者个数:";
cout<<b<<endl;
reader *A=new reader[b];
ifstream is("reader.txt",ios_base::binary);
if(is)


for(i=0;i<b;i++)

is.read((char *)&A[i],sizeof(A[i]));


else

cout<<"txt文件打开出错"<<endl;

is.close();
cout<<"请输入你要查找读者的名字:";
cin>>a;
for(i=0;i<b;i++)

if(strcmp(A[i].getname(),a)==0)

cout<<"编号 年龄 名字 借书情况 "<<endl;
cout<<A[i].getnumber()<<" "<<A[i].getage()<<" "<<A[i].getname()<<" "<<A[i].getborrowbook()<<endl;
h++;


if(h==0)cout<<"没有这个读者!";

*/

void Librarianland() //管理员登陆函数

int q,l=1,i,h;
system("cls");
system("color 2e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<"现在进行身份确认,请输入口令:";
cin>>i;
while(l)

if(i==00000)

system("cls");
system("color 3e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<"|*******" <<"0,返回上一级菜单."<<" ******|"<<endl;
cout<<" "<<"|*******" <<"1,查询图书馆管理员的信息"<<" ******|"<<endl;
cout<<" "<<"|*******" <<"2,存入新的管理员信息. "<<" ******|"<<endl;
cout<<" "<<"|*******" <<"3,修改图书管理员的信息"<<" ******|"<<endl;
cout<<" "<<"|*******" <<"4,新增图书"<<" ******|"<<endl;
cout<<" "<<"|*******" <<"5,删除图书"<<" ******|"<<endl;
cout<<"请选择执行的操作:";
cin>>q;
if(q>=0&&q<6)

switch(q)

case 0:
l=0;
break;
case 1:serchLaninf();
system("pause");
break;
case 2:storelibrarian();
system("pause");
case 3:reLaninf();
system("pause");
break;
case 4:
void aadbook();
aadbook();
break;
case 5:
void delate();
delate();
break;
default:
break;


else

system("cls");
system("color 4e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<"操作无效!"<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
system("pause");


else

system("cls");
system("color 2e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<" 身份确认失败"<<endl;
cout<<" "<<" 是否重新确认!"<<endl;
cout<<" "<<"重新确认请按请按1,放弃请按0"<<endl;
cout<<" ";
cin>>h;
if(h==0) l=0;
if(h==1)

system("cls");
system("color 2e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<"请再次输入口令:";
cin>>i;






void studentland() //学生登陆函数

int h;
char l='y';
while(l=='y')

system("cls");
system("color 3e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<"****** "<<"|输出藏书信息,请按1 | "<<"******"<<endl;
cout<<" "<<"****** "<<"|查询图书馆的总信息,请按2| "<<"******"<<endl;
cout<<" "<<"****** "<<"|按书名查找图书,请按3 | "<<"******"<<endl;
cout<<" "<<"****** "<<"|查询读者的信息,请按4 | "<<"******"<<endl;
cout<<" "<<" ****** "<<"|返回上一级菜单,请按0 | "<<"******"<<endl;
cout<<"请选择您将执行的操作:";
cin>>h;
if(h>=0&&h<5)
switch(h)

case 0:
l='n';
break;
case 1:outbookinf();
system("pause");
break;
case 2:libary();
system("pause");
break;
case 3:searchbook();
system("pause");
break;
case 4:seachreader();
system("pause");
break;

else

system("cls");
system("color 4e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<"您的操作是无效的!!!!"<<endl;
system("pause");




void main() // 主函数

int h,l=1;
while(l)

system("cls");
system("color 7c");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<"图书管理系统"<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" ------------------"<<endl;
cout<<" "<<"||管理员登陆 请按1||"<<endl;
cout<<" "<<"||学生登陆 请按2 ||"<<endl;
cout<<" "<<"||退出系统 请按0 ||"<<endl;
cout<<" -------------------"<<endl;
cout<<""<<endl;
cout<<" 请您选择登陆方式:";
cin>>h;
if(h>=0&&h<3)

switch(h)

case 0:
cout<<"谢谢光临本图书馆!"<<endl;
exit(0);
case 1:
Librarianland();
system("pause");
break;
case 2:
studentland();
system("pause");
break;


else

system("cls");
system("color 4e");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<"您的操作是无效的!!!!"<<endl;
system("pause");



图书馆的管理系统。本回答被提问者采纳
参考技术B // SnakeDlg.h : 头文件
//
#pragma once
#include "afxwin.h"
// CSnakeDlg 对话框
class CSnakeDlg : public CDialog

// 构造
public:
CSnakeDlg(CWnd* pParent = NULL); // 标准构造函数
// 对话框数据
enum IDD = IDD_SNAKE_DIALOG ;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
HICON m_hIcon;
// 游戏场景数据
CRect m_ScrDeviceRect;
CSize m_ScrDeviceSize, m_ScrLogicalSize;
int m_iLevel, m_iScore;
bool m_bPause, m_bGameOver;
CPen m_penSnake, m_penScrBk;
CWinThread *m_pGameThread;
// “贪吃蛇”数据
CList<CPoint> m_SnakeBody;
int m_iLength, m_iCourse, m_iRealCourse;
CPoint m_ptFood;
// 自定义成员函数
void LPtoDP(CPoint &Point);
void DPtoLP(CPoint &Point);
void GameInit();
bool IsInScreen(CPoint &Point);
bool IsGameOver();
bool IsFoodOK();
static UINT GameThread(LPVOID pParam);
// 生成的消息映射函数
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnBnClickedButtonLevel();
afx_msg void OnBnClickedButtonStart();
afx_msg void OnBnClickedButtonPause();
afx_msg void OnBnClickedButtonExit();
DECLARE_MESSAGE_MAP()
virtual void OnOK();
virtual void OnCancel();
virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
virtual BOOL PreTranslateMessage(MSG* pMsg);
;

[点击此处复制到剪贴板] [ - ]CODE:
// SnakeDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "Snake.h"
#include "SnakeDlg.h"
#include "LevelDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialog

public:
CAboutDlg();
// 对话框数据
enum IDD = IDD_ABOUTBOX ;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
;
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)


void CAboutDlg::DoDataExchange(CDataExchange* pDX)

CDialog::DoDataExchange(pDX);

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CSnakeDlg 对话框
CSnakeDlg::CSnakeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSnakeDlg::IDD, pParent)
, m_iLevel(1)
, m_iScore(0)
, m_bPause(false)
, m_iLength(3)
, m_iCourse(1)
, m_iRealCourse(1)
, m_bGameOver(true)

m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

void CSnakeDlg::DoDataExchange(CDataExchange* pDX)

CDialog::DoDataExchange(pDX);
//DDX_Control(pDX, IDC_SCREEN, m_Screen);
DDX_Text(pDX, IDC_TEXT_LEVEL, m_iLevel);
DDX_Text(pDX, IDC_TEXT_SCORE, m_iScore);
DDX_Text(pDX, IDC_TEXT_LENGTH, m_iLength);

BEGIN_MESSAGE_MAP(CSnakeDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//AFX_MSG_MAP
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_BUTTON_EXIT, &CSnakeDlg::OnBnClickedButtonExit)
ON_BN_CLICKED(IDC_BUTTON_LEVEL, &CSnakeDlg::OnBnClickedButtonLevel)
ON_BN_CLICKED(IDC_BUTTON_START, &CSnakeDlg::OnBnClickedButtonStart)
ON_BN_CLICKED(IDC_BUTTON_PAUSE, &CSnakeDlg::OnBnClickedButtonPause)
END_MESSAGE_MAP()
// CSnakeDlg 消息处理程序
BOOL CSnakeDlg::OnInitDialog()

CDialog::OnInitDialog();
// 将“关于...”菜单项添加到系统菜单中。
// IDM_ABOUTBOX 必须在系统命令范围内。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)

CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())

pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);


// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
GetDlgItem(IDC_SCREEN)->GetWindowRect(m_ScrDeviceRect);
m_ScrDeviceSize.cx=m_ScrDeviceRect.right-m_ScrDeviceRect.left;
m_ScrDeviceSize.cy=m_ScrDeviceRect.bottom-m_ScrDeviceRect.top;
#ifdef _DEBUG
afxDump<<"Screen Device Rect : "<<m_ScrDeviceRect<<"\n";
afxDump<<"Screen Device Size : "<<m_ScrDeviceSize<<"\n";
#endif // _DEBUG
m_ScrLogicalSize.cx=m_ScrDeviceSize.cx/10;
m_ScrLogicalSize.cy=m_ScrDeviceSize.cy/10;
#ifdef _DEBUG
afxDump<<"Screen Logical Size : "<<m_ScrLogicalSize<<"\n";
#endif // _DEBUG
GetDlgItem(IDC_BUTTON_PAUSE)->EnableWindow(FALSE);
m_penSnake.CreatePen(PS_SOLID, 12, RGB(0, 0, 0));
m_penScrBk.CreatePen(PS_SOLID, 12, RGB(255, 255, 255));
GameInit();
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE

void CSnakeDlg::OnSysCommand(UINT nID, LPARAM lParam)

if ((nID & 0xFFF0) == IDM_ABOUTBOX)

CAboutDlg dlgAbout;
dlgAbout.DoModal();

else

CDialog::OnSysCommand(nID, lParam);


// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
// 这将由框架自动完成。
void CSnakeDlg::OnPaint()

if (IsIconic())

CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);

else

CClientDC DC(GetDlgItem(IDC_SCREEN));
CPen *pOldPen=DC.SelectObject(&m_penScrBk);
for (int i=1; i<=m_ScrLogicalSize.cx; i++)
for (int j=1; j<=m_ScrLogicalSize.cy; j++)

CPoint ptTemp(i, j);
LPtoDP(ptTemp);
DC.MoveTo(ptTemp);
DC.LineTo(ptTemp);
DPtoLP(ptTemp);

pOldPen=DC.SelectObject(&m_penSnake);
if (IsInScreen(m_SnakeBody.GetHead()))

LPtoDP(m_SnakeBody.GetHead());
DC.MoveTo(m_SnakeBody.GetHead());
DC.LineTo(m_SnakeBody.GetHead());
DPtoLP(m_SnakeBody.GetHead());

POSITION Pos=m_SnakeBody.GetHeadPosition();
m_SnakeBody.GetNext(Pos);
for (int i=1; i<m_SnakeBody.GetSize(); i++)

CPoint ptTemp=m_SnakeBody.GetNext(Pos);
LPtoDP(ptTemp);
DC.MoveTo(ptTemp);
DC.LineTo(ptTemp);
DPtoLP(ptTemp);

LPtoDP(m_ptFood);
DC.MoveTo(m_ptFood);
DC.LineTo(m_ptFood);
DPtoLP(m_ptFood);
DC.SelectObject(pOldPen);
CDialog::OnPaint();


//当用户拖动最小化窗口时系统调用此函数取得光标显示。
//
HCURSOR CSnakeDlg::OnQueryDragIcon()

return static_cast<HCURSOR>(m_hIcon);

void CSnakeDlg::OnOK()

// TODO: 在此添加专用代码和/或调用基类

void CSnakeDlg::OnCancel()

// TODO: 在此添加专用代码和/或调用基类
if (m_bPause) m_pGameThread->ResumeThread();
if (!m_bGameOver)

m_bGameOver=true;
::WaitForSingleObject(m_pGameThread->m_hThread, INFINITE);

CDialog::OnCancel();

void CSnakeDlg::WinHelp(DWORD dwData, UINT nCmd)

// TODO: 在此添加专用代码和/或调用基类
CAboutDlg Dlg;
Dlg.DoModal();

void CSnakeDlg::OnBnClickedButtonLevel()

// TODO: 在此添加控件通知处理程序代码
CLevelDlg Dlg;
if (Dlg.DoModal()==IDOK) m_iLevel=Dlg.m_iLevel;
UpdateData(FALSE);

void CSnakeDlg::OnBnClickedButtonStart()

// TODO: 在此添加控件通知处理程序代码
GetDlgItem(IDC_BUTTON_LEVEL)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_START)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_PAUSE)->EnableWindow(TRUE);
GetDlgItem(IDC_SCREEN)->SetFocus();
GameInit();
UpdateData(FALSE);
OnPaint();
m_bGameOver=false;
m_pGameThread=AfxBeginThread(GameThread, this);

void CSnakeDlg::OnBnClickedButtonPause()

// TODO: 在此添加控件通知处理程序代码
m_bPause=!m_bPause;
if (m_bPause)

m_pGameThread->SuspendThread();
GetDlgItem(IDC_BUTTON_PAUSE)->SetWindowText("继续游戏");
GetDlgItem(IDC_BUTTON_LEVEL)->EnableWindow(TRUE);

else

m_pGameThread->ResumeThread();
GetDlgItem(IDC_BUTTON_PAUSE)->SetWindowText("暂停游戏");
GetDlgItem(IDC_BUTTON_LEVEL)->EnableWindow(FALSE);


void CSnakeDlg::OnBnClickedButtonExit()

// TODO: 在此添加控件通知处理程序代码
OnCancel();

BOOL CSnakeDlg::PreTranslateMessage(MSG* pMsg)

// TODO: 在此添加专用代码和/或调用基类
if (pMsg->message==WM_KEYDOWN)

switch (toupper((int)pMsg->wParam))

case 'W':
case 38:
if (m_iRealCourse!=2) m_iCourse=4;
break;
case 'S':
case 40:
if (m_iRealCourse!=4) m_iCourse=2;
break;
case 'A':
case 37:
if (m_iRealCourse!=1) m_iCourse=3;
break;
case 'D':
case 39:
if (m_iRealCourse!=3) m_iCourse=1;
break;


return CDialog::PreTranslateMessage(pMsg);

// 自定义成员函数
void CSnakeDlg::DPtoLP(CPoint &Point)

Point.x=(Point.x+5)/10;
Point.y=(Point.y+5)/10;

void CSnakeDlg::LPtoDP(CPoint &Point)

Point.x=Point.x*10-5;
Point.y=Point.y*10-5;

void CSnakeDlg::GameInit()

m_iScore=0;
m_bPause=false;
m_iLength=3;
m_iCourse=1;
m_SnakeBody.RemoveAll();
for (int i=10; i>7; i--)

CPoint ptTemp(i, 10);
m_SnakeBody.AddTail(ptTemp);

m_ptFood.x=10000;
m_ptFood.y=10000;

bool CSnakeDlg::IsInScreen(CPoint &Point)

return 1<=m_SnakeBody.GetHead().x && m_SnakeBody.GetHead().x<=m_ScrLogicalSize.cx && 1<=m_SnakeBody.GetHead().y && m_SnakeBody.GetHead().y<=m_ScrLogicalSize.cy;

bool CSnakeDlg::IsGameOver()

if (m_SnakeBody.GetHead().x<1 || m_SnakeBody.GetHead().x>m_ScrLogicalSize.cx) return true;
if (m_SnakeBody.GetHead().y<1 || m_SnakeBody.GetHead().y>m_ScrLogicalSize.cy) return true;
POSITION Pos=m_SnakeBody.GetHeadPosition();
m_SnakeBody.GetNext(Pos);
for (int i=1; i<m_SnakeBody.GetSize(); i++)
if (m_SnakeBody.GetHead()==m_SnakeBody.GetNext(Pos)) return true;
return false;

bool CSnakeDlg::IsFoodOK()

POSITION Pos=m_SnakeBody.GetHeadPosition();
for (int i=0; i<m_SnakeBody.GetSize(); i++)
if (m_ptFood==m_SnakeBody.GetNext(Pos)) return false;
return true;

UINT CSnakeDlg::GameThread(LPVOID pParam)

CSnakeDlg *pDlg=(CSnakeDlg*)pParam;
CClientDC DC(pDlg->GetDlgItem(IDC_SCREEN));
bool bMakeFood=true, bGameOver=false;
srand((unsigned)time(NULL));
while (!bGameOver && !pDlg->m_bGameOver)

CPen *pOldPen;
::Sleep(500/pDlg->m_iLevel);
if (bMakeFood)

pOldPen=DC.SelectObject(&pDlg->m_penScrBk);
pDlg->LPtoDP(pDlg->m_ptFood);
DC.MoveTo(pDlg->m_ptFood);
DC.LineTo(pDlg->m_ptFood);
pDlg->DPtoLP(pDlg->m_ptFood);
DC.SelectObject(pOldPen);
do

pDlg->m_ptFood.x=rand()%pDlg->m_ScrLogicalSize.cx+1;
pDlg->m_ptFood.y=rand()%pDlg->m_ScrLogicalSize.cy+1;
while(!pDlg->IsFoodOK());
pOldPen=DC.SelectObject(&pDlg->m_penSnake);
pDlg->LPtoDP(pDlg->m_ptFood);
DC.MoveTo(pDlg->m_ptFood);
DC.LineTo(pDlg->m_ptFood);
pDlg->DPtoLP(pDlg->m_ptFood);
DC.SelectObject(pOldPen);
bMakeFood=false;

CPoint ptTarg=pDlg->m_SnakeBody.GetHead(), ptPrev=pDlg->m_SnakeBody.GetTail();
pDlg->m_SnakeBody.RemoveTail();
switch (pDlg->m_iCourse)

case 1:
ptTarg.x++;
break;
case 2:
ptTarg.y++;
break;
case 3:
ptTarg.x--;
break;
case 4:
ptTarg.y--;
break;

pDlg->m_SnakeBody.AddHead(ptTarg);
pDlg->m_iRealCourse=pDlg->m_iCourse;
if (pDlg->m_SnakeBody.GetHead()!=pDlg->m_ptFood)

pOldPen=DC.SelectObject(&pDlg->m_penScrBk);
pDlg->LPtoDP(ptPrev);
DC.MoveTo(ptPrev);
DC.LineTo(ptPrev);
pDlg->DPtoLP(ptPrev);
DC.SelectObject(pOldPen);

else

pDlg->m_SnakeBody.AddTail(ptPrev);
pDlg->m_iLength=(int)pDlg->m_SnakeBody.GetSize();
CString sTemp;
sTemp.Format("%d", pDlg->m_iLength);
pDlg->GetDlgItem(IDC_TEXT_LENGTH)->SetWindowText(sTemp);
pDlg->m_iScore=pDlg->m_iScore+pDlg->m_iLevel;
sTemp.Format("%d", pDlg->m_iScore);
pDlg->GetDlgItem(IDC_TEXT_SCORE)->SetWindowText(sTemp);
pDlg->m_ptFood.x=10000;
pDlg->m_ptFood.y=10000;
bMakeFood=true;

if (!(bGameOver=pDlg->IsGameOver()))

pOldPen=DC.SelectObject(&pDlg->m_penSnake);
pDlg->LPtoDP(pDlg->m_SnakeBody.GetHead());
DC.MoveTo(pDlg->m_SnakeBody.GetHead());
DC.LineTo(pDlg->m_SnakeBody.GetHead());
pDlg->DPtoLP(pDlg->m_SnakeBody.GetHead());
DC.SelectObject(pOldPen);

pOldPen=DC.SelectObject(&pDlg->m_penSnake);
pDlg->LPtoDP(pDlg->m_ptFood);
DC.MoveTo(pDlg->m_ptFood);
DC.LineTo(pDlg->m_ptFood);
pDlg->DPtoLP(pDlg->m_ptFood);
DC.SelectObject(pOldPen);

if (!pDlg->m_bGameOver)

pDlg->GetDlgItem(IDC_BUTTON_LEVEL)->EnableWindow(TRUE);
pDlg->GetDlgItem(IDC_BUTTON_START)->EnableWindow(TRUE);
pDlg->GetDlgItem(IDC_BUTTON_PAUSE)->EnableWindow(FALSE);
pDlg->m_bGameOver=true;
AfxMessageBox("游戏已经结束 !");

return 0;
参考技术C 很长 很和谐 参考技术D 牛! 第5个回答  2008-06-11 这个有难度啊!!!

世界难题!高分悬赏破译密码第一关!

英国专家西蒙辛格向全世界悬赏15000美圆征求破译十道密码。至今无人获奖。

原文:《第一关:简单的单字母替换密码》
BT JPX RMLX PCUV AMLX ICVJP IBTWXVR CI M LMT’R PMTN, MTN
YVCJX CDXV MWMBTRJ JPX AMTNGXRJBAH UQCT JPX QGMRJXV CI JPX
YMGG CI JPX HBTW’R QMGMAX MTN JPX HBTW RMY JPX QMVJ CI JPX
PMTN JPMJ YVCJX. JPXT JPX HBTW’R ACUTJXTMTAX YMR APMTWXN,
MTN PBR JPCUWPJR JVCUFGXN PBL, RC JPMJ JPX SCBTJR CI PBR
GCBTR YXVX GCCRXN, MTN PBR HTXXR RLCJX CTX MWMBTRJ
MTCJPXV . JPX HBTW AVBXN MGCUN JC FVBTW BT JPX MRJVCGCWXVR,
JPX APMGNXMTR, MTN JPX RCCJPRMEXVR. MTN JPX HBTW RQMHX,
MTN RMBN JC JPX YBRX LXT CI FMFEGCT, YPCRCXDXV RPMGG VXMN
JPBR YVBJBTW, MTN RPCY LX JPX BTJXVQVXJMJBCT JPXVXCT,
RPMGG FX AGCJPXN YBJP RAMVGXJ, MTN PMDX M APMBT CI WCGN
MFCUJ PBR TXAH, MTN RPMGG FX JPX JPBVN VUGXV BT JPX
HBTWNCL. JPXT AMLX BT MGG JPX HBTW’R YBRX LXT; FUJ JPXE
ACUGN TCJ VXMN JPX YVBJBTW, TCV LMHX HTCYT JC JPX HBTW JPX
BTJXVQVXJMJBCT JPXVXCTI. JPXT YMR HBTW FXGRPMOOMV WVWMJGE
JVCUFGXN, MTN PBR ACUTJXTMTAX YMR APMTWXN BT PBL, MTN PBR
GCVNR YXVX MRJCTBRPXN. TCY JPX KUXXT, FE VXMRCT CI JPX
YCVNR CI JPX HBTW MTN PBR GCVNR, AMLX BTJC JPX FMTKUXJ
PCURX; MTN JPX KUXXT RQMHX MTN RMBN, C HBTW, GBDX ICVXDXV;
GXJ TCJ JPE JPCUWPJR JVCUFGX JPXX, TCV GXJ JPE ACUTJXTMTAX
FX APMTWXN; JPXVX BR M LMT BT JPE HBTWNCL , BT YPCL BR JPX
RQBVBJ CI JPX PCGE WCNR ; MTN BT JPX NMER CI JPE IMJPXV
GBWPJ MTN UTNXVRJMTNBTW MTN YBRNCL , GBHX JPX YBRNCL CI JPX
WCNR, YMR ICUTN BT PBL; YPCL JPX HBTW TXFUAPMNTXOOMV JPE
IMJPXV, JPX HBTW, B RME, JPE IMJPXV, LMNX LMRJXV CI JPX
LMNBABMTR, MRJVCGCWXVR, APMGNXMTR, MTN RCCJPRMEXVR;
ICVMRLUAP MR MT XZAXGGXTJ RQBVBJ, MTN HTCYGXNWX, MTN
UTNXVRJMTNBTW, BTJXVQVXJBTW CI NVXMLR, MTN RPCYBTW CI PMVN
RXTJXTAXR, MTN NBRRCGDBTW CI NCUFJR, YXVX ICUTN BT JPX
RMLX NMTBXG, YPCL JPX HBTW TMLXN FXGJXRPMOOMV; TCY GXJ
NMTBXG FX AMGGXN, MTN PX YBGG RPCY JPX BTJXVXJMJBCT. JPX
IBVRJ ACNXYCVN BR CJPXGGC.

楼主备注:
解释一下,所谓“单字母替换密码”就是密码的一个字母只代表明码的一个字母,但是各密码字母与字母表的顺序无关,比如A如果是m,那么B不一定是n。这是跟恺撒密码不同之处(恺撒密码的A如果是m,那么B一定是n)。
破译“单字母替换密码”就是要通过英文的特点,寻找其中的突破点,然后破译整个字母表,进而破译全文。

希望大家玩得高兴!
谢谢大家的参与!
大家还可以去破译第二关!
第三关字母太多,待俺慢慢输入后公布.400分奖励哦!

至今没有人宣布“密码单词”。
每题都有其“密码单词”,凭10个“密码单词”向西蒙辛格领取奖金!

做完了,谜底是这样的:
in the same hour came forth fingers of a man’s hand, and
wrote over against the candlestick upon the plaster of the
wall of the king’s palace and the king saw the part of the
hand that wrote. then the king’s countenance was changed,
and his thoughts troubled him, so that the joints of his
loins were loosed, and his knees smote one against
another . the king cried aloud to bring in the astrologers,
the chaldeans, and the soothsayers. and the king spake,
and said to the wise men of babylon, whosoever shall read
this writing, and show me the interpretation thereon,
shall be clothed with scarlet, and have a chain of gold
about his neck, and shall be the third ruler in the
kingdom. then came in all the king’s wise men; but they
could not read the writing, nor make known to the king the
interpretation thereonf. then was king belshazzar grgatly
troubled, and his countenance was changed in him, and his
lords were astonished. now the queen, by reason of the
words of the king and his lords, came into the banquet
house; and the queen spake and said, o king, live forever;
let not thy thoughts trouble thee, nor let thy countenance
be changed; there is a man in thy kingdom , in whom is the
spirit of the holy gods ; and in the days of thy father
light and understanding and wisdom , like the wisdom of the
gods, was found in him; whom the king nebuchadnezzar thy
father, the king, i say, thy father, made master of the
madicians, astrologers, chaldeans, and soothsayers;
forasmuch as an excellent spirit, and knowledge, and
understanding, interpreting of dreams, and showing of hard
sentences, and dissolving of doubts, were found in the
same daniel, whom the king named belteshazzar; now let
daniel be called, and he will show the interetation. the
first codeword is othello
等有空了再说过程

过程补充:
因为文字这么多,就可以从词频入手了。
第一步:
英文字母出现频率
先从baidu上搜索出英文字母词频分布情况:
高频字母:E、 T、A、O、N、I、R、S、H
中频字母:D、L、U、C、M
低频字母:P、F、Y、W、G、B、Y(v?)
稀频字母:J、K、Q、X、Z
第二步:
确定字母e
再统计一个原文中各个字母出现的频率。具体情况我就不列出来了。全部字母1405字,字母X出现了167次,比排名第二的T的133次要高出很多

,几乎可以肯定X=e。(为了方便替换,在word里将全部大写字母换成小写)。然后,因为Z和S都只出现了一次,于是大胆猜测它们就是x和e

。而且在e破译出来后,有eZ***的词出现,一般英文中ex***的词不少,于是暂定Z~x,S~z。因为x和z出现次数也不多,暂时这么估计也不会

太影响总体。
第三步
从短单词入手
在e取代了X后,观察到全文中有很多‘JPe’这样的词出现,很容易就会想到它们就是‘the’。于是J=t,P=h。
再观察只有一个字母的单词,文中出现过3次‘M’和1次‘B’用一个字母作词的情况,这与英文中的‘a’和‘I’作为单词几乎是对应的。鉴

于‘I’在单独作单词时通常在句首,观察M和B的位置,可以得到M=a,B=i。
还有文中的'R情况,根据英文的所有格用法,容易想到R=s。
第四步
利用已有条件,解决特征单词
因为一眼瞥见了替换后的‘saE’,于是查一下金山词霸,从sad/sap/sat/saw/say中,排除已用字母t的sat,根据词的位置基本可以排除掉形

容词sad,再根据文中还多次出现‘thE’这个词,用w、p或d套用都不能成词,而‘thy’是古英文中‘你’的意思,还可以接受E=y。
又,在替换后‘iT’多次出现,估计T~f或T~n。根据词频规律以及T在本文中出现的高达133次来看,T不会是低频字母f,所以T=n。
很多地方的‘anN’使人很容易将N=d推断出来。
第五步
解决剩下的高词频字母
在出现100次以上的字母中,只剩下C还没有对应,而词频排名第四的o也还没有对应,可以猜想C~o,文中‘CI’这样的词出现多次,估计为‘

of’,而f对应的词频和I出现的次数也相当。因此确定C=o,I=f。
高词频还有剩下有r,而文中很多词的后缀是‘-eV’,所以判断V=r。多个地方验证也还可行。
第六步
逐渐解决剩下的字母
根据后缀‘-inW’来找出W=g,根据两个‘Yrote’来得到Y=w,根据‘Hnown’和‘Hing's’来得到H=k。
剩下的就简单了:G=l,Q=p,U=u,K=q,A=c,L=m,F=b,D=v。
最后剩下个O~j。
第七步
验证
发现有的单词出错,出现一次的‘zoints’和‘belshajjar’都不是单词,试着将‘z’和‘j’换一下,就正确了,而且后者是圣经里的名词

,还有古英文的thy和thee。应该没问题了。所以最后O=z,S=j,再确定前边的Z=x。就完了。
参考技术A 将楼主的题目复制到文本里,只处理前1200个字符

字符统频 |标准| > 4.000000

频次表
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
00 0 0 0 0 0 0 0 0 0 0 17 0 0 17 0 0
01 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
02 348 0 0 0 0 0 0 0 0 0 0 0 17 0 6 0
03 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
04 0 18 48 58 3 5 11 30 16 12 76 1 12 68 36 2
05 67 7 52 1 75 13 40 23 93 19 0 0 0 0 0 0
06 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
07 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
08 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
09 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0a 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 4
0b 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0c 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0d 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0e 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0f 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

T值表
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
00 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 5.70 -2.17 -2.17 5.70 -2.17 -2.17
01 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
02158.88 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 5.70 -2.17 0.61 -2.17
03 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -1.71 -2.17 -2.17 -2.17 -2.17
04 -2.17 6.16 20.04 24.67 -0.78 0.14 2.92 11.71 5.24 3.38 33.00 -1.71 3.38 29.30 14.49 -1.24
05 28.84 1.07 21.90 -1.71 32.54 3.85 16.34 8.47 40.87 6.62 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
06 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
07 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
08 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
09 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
0a -2.17 -0.32 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -0.32
0b -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
0c -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
0d -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
0e -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17
0f -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17 -2.17

下面是敏感信息
0a 17 5.6980(回车换行)
0d 17 5.6980
20 348 158.8799
2c , 17 5.6980
41 A 18 6.1608
42 B 48 20.0444
43 C 58 24.6722
47 G 30 11.7142
48 H 16 5.2353
4a J 76 33.0024
4d M 68 29.3001
4e N 36 14.4910
50 P 67 28.8373
52 R 52 21.8955
54 T 75 32.5396
56 V 40 16.3421
57 W 23 8.4747
58 X 93 40.8697
59 Y 19 6.6236

计算相应频次,发现和英文字母出现的频次相近,由T值分析不是耦合现象,这是典型的代替作业模式;

英文字母使用频率表:(%)
A 8.19 B 1.47 C 3.83 D 3.91 E 12.25 F 2.26 G 1.71
H 4.57 I 7.10 J 0.14 K 0.41 L 3.77 M 3.34 N 7.06
O 7.26 P 2.89 Q 0.09 R 6.85 S 6.36 T 9.41
U 2.58 V 1.09 W 1.59 X 0.21 Y 1.58 Z 0.08

高频字母设字: eg(X = E)

利用词的频率特性,除了汉字的构词特性外,英文单词也存在明显的构词和字母跟随关系,比如在10000个英文单词中
(包含功能词汇),and出现142次,the出现420次等等,同时也根据英文语法关系可是设字破译,比如文中出现的'
后面的字符一般是s或者m,随意可以假定(R=S)

具体设字破译阶段bcgzcr已经分析的很透彻了,我在这里只是给出了一般意义上的此类密码的破译思路.

在设立字符替代的基础上,反复带入进行验证,知道带入字符不出现矛盾的情况下,由英文单词的特性来推全所有的
密钥即可.

本文密钥:

明文: ABCDEFGHIJKLMNOPQRSTUVWXYZ
密钥: CIOVYBLKFTQMADZHPSJNURGEWX
参考技术B #include"stdio.h"
#include"ctype.h"
#include"stdlib.h"

main(int argc ,char *argv[])


FILE *fp_ciper,*fp_plain; //密文与明文的文件指针
char ch_ciper,ch_plain;
int i,temp=0; //i用来存最多次数的下标
//temp用在求最多次数时用
int key; //密钥
int j;
int num[26]; //保存密文中字母出现次数

for(i = 0;i < 26; i++)
num = 0; //进行对num[]数组的初始化

printf("======================================================\n");
printf("------------------BY 安美洪 design--------------------\n");
printf("======================================================\n");

if(argc!=3)

printf("此为KAISER解密用法:[文件名] [密文路径] [明文路径]\n");
printf("如:decryption F:\ciper_2_1.txt F:\plain.txt\n");
//判断程序输入参数是否正确

if((fp_ciper=fopen(argv[1],"r"))==NULL)

printf("打开密文出错!解密失败\n");
exit(0);

while((ch_ciper=fgetc(fp_ciper))!=EOF)
switch(ch_ciper)

case 'A':num[0]=num[0]+1; break; //统计密文各字母出现次数
case 'B':num[1]=num[1]+1; break; //与上同,下边一样
case 'C':num[2]=num[2]+1; break;
case 'D':num[3]=num[3]+1; break;
case 'E':num[4]=num[4]+1; break;
case 'F':num[5]=num[5]+1; break;
case 'G':num[6]=num[6]+1; break;
case 'H':num[7]=num[7]+1; break;
case 'I':num[8]=num[8]+1; break;
case 'J':num[9]=num[9]+1; break;
case 'K':num[10]=num[10]+1;break;
case 'L':num[11]=num[11]+1;break;
case 'M':num[12]=num[12]+1;break;
case 'N':num[13]=num[13]+1;break;
case '0':num[14]=num[14]+1;break;
case 'P':num[15]=num[15]+1;break;
case 'Q':num[16]=num[16]+1;break;
case 'R':num[17]=num[17]+1;break;
case 'S':num[18]=num[18]+1;break;
case 'T':num[19]=num[19]+1;break;
case 'U':num[20]=num[20]+1;break;
case 'V':num[21]=num[21]+1;break;
case 'W':num[22]=num[22]+1;break;
case 'X':num[23]=num[23]+1;break;
case 'Y':num[24]=num[24]+1;break;
case 'Z':num[25]=num[25]+1;break;


fclose(fp_ciper);

for(i=0;i<26;i++)
if(num>temp)

j=i; // 求出最大次数的下下标
temp=num;

if(j<5)
key=(j+1+26)-5; //是按字母表的第几位计算
//而不是按下标,故加1
//5是指E在字母表中的位序
else
key=(j+1)-5;

if((fp_ciper=fopen(argv[1],"r"))==NULL)

printf("再次打开密文出错!解密失败\n");
exit(0);
//再次打开密文,进行解密
if((fp_plain=fopen(argv[2],"w"))==NULL)

printf("打开或建立明文文件出错!解密失败\n");
exit(0);
//把明文存到此文件
while((ch_ciper=fgetc(fp_ciper))!=EOF)

if(ch_ciper > 'E')
ch_plain=(((ch_ciper-'A'-key)%26)+'A'); //解密
else
ch_plain=(((ch_ciper-'A'-key+26)%26)+'A'); //解密
ch_plain=tolower(ch_plain); //把大写明文转化为小写
fputc(ch_plain,fp_plain); //把明文写到文件文件plain

fclose(fp_ciper);
fclose(fp_plain);
printf("解密成功,密钥KEY=%d,明文已保存到文件中,谢谢使用!\n",key);
参考技术C 呵呵 这也算密码。 就这种移位密码 和明文有什么区别。
编个小循环程序 循环26次 什么问题都搞定了。
太业余了。 来点难的。
for(i=1,i<=26,i++)
替代 chr(i+ ??)(目的是i=1-26 与chr(x)里的x顺序一致) ;
printf(chr(x) 打印到屏幕
最后看 屏幕上26 行哪个是能看懂的语言。。

呵呵。 不用全部都试 只要 整篇里的一句就可以。

这中方法基本能解决所有移位密码( 其实这还称不上密码)
参考技术D 郁闷,慢了一步
不过第一关真的是太简单了,JPX也是太明显了
拿到Word里去慢慢替换(区分大小写——换了的都换成小写,还是原来的密文就保留原来的大写)10分钟应该搞定。

以上是关于高分悬赏急求一段源代码的主要内容,如果未能解决你的问题,请参考以下文章

远程连接sql 2000 不正确 急求解答 高分悬赏

急求一流高手帮忙中译英,绝对真诚高分悬赏1

高分求一段 PHP 实时显示倒计时 代码

急求一段JS,让网页字体大小随分辨率变化而自适应

急求 MD5的加密解密算法,用C++实现的源代码 高分答谢

高分悬赏:有关ARM汇编的一点疑问。下面的代码是啥意思?