# 我写了一个密码转换的一个小程序，在VS2013中能正确编译和链接，就是不能运行

//头文件

//标头.h

#ifndef mima
#define mima

class Point
{
private:

int x; //横坐标
int y; //纵坐标

public:
Point(){};
Point(int x_m, int y_m){ x = x_m; y = y_m;};
~Point(){};
int getX() { return x; }
int getY() { return y; }
void changeX(int x_m) { x = x_m; }
void changeY(int y_m) { y = y_m; }
};

#endif

//主函数

//源.cpp

#include<iostream>
#include"标头.h"
#include<string>

using namespace std;
char M_code[5][6] = {
"QWERT",
"YUIOP",
"ASDFG",
"HJKLX",
"CVBNM"
}; //密钥
string  panduan(string & A) //判断长度A必须为偶数，不是偶数后面加个A；
{
if (A.length() % 2)
{
A = A + "A";
}
return A;

}
string toUpper(string & str) //小写字母转换成大写字母
{
int length_m;
length_m = str.length();
for (int i = 0; i < length_m; i++)
{
if (str[i] > 96 && str[i] < 123)
str[i] -= 32;
}
return str;
}
Point dingwei(const string & A, int m) //在密钥中定位明文字母
{
int i = 0; //横
int j = 0; //纵

for (; A[m] != M_code[i][j]; i++)
for (; A[m] != M_code[i][j]; j++)
if (j >= 6)
break;
Point Point_m(i, j);
return Point_m;
}
void diaohuan(Point &A, Point &B) //调换Y值
{
int t = A.getY();
A.changeY(B.getY());
B.changeY(t);
}
int main()
{
string cinstring; //输入的明文
string miwen; //密文
cout << "请输入明文：" << endl;
cin >> cinstring;
cinstring = toUpper(cinstring);
cinstring = panduan(cinstring);
cout << cinstring << endl;
Point M, N;
for (int i_m = 0; i_m <= cinstring.length(); i_m += 2)
{
M = dingwei(cinstring, i_m );
N = dingwei(cinstring, i_m + 1);
diaohuan(M, N);
miwen += M_code[M.getX()][M.getY()];
miwen += M_code[N.getX()][N.getY()];

}
cout << "密文为：" << miwen << endl;

return 0;
}
/*我的思路是先建立一个5*6的一个二维数组作为密钥

*/