可视化地将C++代码从一个程序转移到另一个程序
visual transfering C++ code from one programme to another
所以,我的朋友告诉我,他成功地构建了自己的"谜机",但他使用的程序在我的Windows版本上不起作用。
我昨天安装了微软的visual studio,无法让他的代码在我的上运行。我对编码还很年轻,我希望这里有人能帮助我。我相信问题出在库上,我已经尝试了我所知道的一切,但我不确定我还需要做什么,这会给我带来很多错误,并忽略预编译的头。
这是代码:
#include "iostream"
#include "cstdlib"
#include "string"
#include "stdafx.h" //I added this library because vstudio asked me to do so..?
#include "algorithm"
using namespace std;
int i, j, l, r1, r2, r3, n1, n2, n3, n4, rII, rIII;
string msg;
int rotor1[26] = { 4,10,12,5,11,6,3,16,21,25,13,19,14,22,24,7,23,20,18,15,0,8,1,17,2,9 };
int rotor2[26] = { 0,9,3,10,18,8,17,20,23,1,11,7,22,19,12,2,16,6,25,13,15,24,5,21,14,4 };
int rotor3[26] = { 1,3,5,7,9,11,2,15,17,19,23,21,25,13,24,4,8,22,6,0,10,12,20,18,16,14 };
int reflec[26] = { 24,17,20,7,16,18,11,3,15,23,13,6,14,10,12,8,4,1,5,25,2,22,21,9,0,19 };
char base[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
void RotorInput() {
cout << "Input initial positions (0 to 25):n";
cout << "First rotor: ";
cin >> r1;
cout << "Second rotor: ";
cin >> r2;
cout << "Third rotor: ";
cin >> r3;
}
void RotorInitialization() {
rotate(rotor1, rotor1 + r1, rotor1 + 26);
rotate(rotor2, rotor2 + r2, rotor2 + 26);
rotate(rotor2, rotor2 + r2, rotor2 + 26);
}
void MessageInput() {
cout << "Input your message/code:n";
getline(cin, msg);
getline(cin, msg);
}
void Encription() {
l = msg.size();
for (j = 0; j < l; j++) {
}
for (i = 0; i < l; i++) {
if (msg.at(i) == ' ') {
cout << " ";
}
else {
int x = distance(base, find(base, base + 26, msg.at(i)));
n1 = rotor1[x];
n2 = rotor2[n1];
n3 = rotor3[n2];
n4 = reflec[n3];
n3 = distance(rotor3, find(rotor3, rotor3 + 26, n4));
n2 = distance(rotor2, find(rotor2, rotor2 + 26, n3));
n1 = distance(rotor1, find(rotor1, rotor1 + 26, n2));
cout << base[n1];
rII = (i + r2 + 1) % 26;
rIII = (i + r3 + 1) % 676;
rotate(rotor1, rotor1 + 1, rotor1 + 26);
if (rII == 0) {
rotate(rotor2, rotor2 + 1, rotor2 + 26);
}
else {}
if (rIII == 0) {
rotate(rotor3, rotor3 + 1, rotor3 + 26);
}
else {}
}
}
}
int main()
{
RotorInput();
RotorInitialization();
MessageInput();
Encription();
cout << endl;
system("pause");
return 0;
}
提前感谢!
首先,预编译的头include应该是源文件中的第一行。
此外,我将在所有标准库中由"
、<
或>
分别替换为开头或结尾引号。
对于搜索谷歌后出现在这里的人来说,HEUR/QVM19.1.Malware.Gen是一个360全面安全(防病毒)误报。只需将VS文件夹列入白名单。
我的问题在于,我的代码不是以#include"stdafx.h"开头的,当它开始时,我的病毒会将程序标记为恶意软件。这就是造成这一切混乱的原因。谢谢大家!
相关文章:
- 试图在visual studio上用C++创建一个桌面应用程序
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- VSCode-有一个红色下划线,但程序构建和运行正确,并且出现配音错误
- 我正在尝试使用 c++ 创建一个货币转换程序,我不知道如何继续
- 试图创建一个多线程程序来查找0-100000000之间的总素数
- 我试图制作一个程序,要求用户输入问题和答案,但程序循环不正确
- 为什么它只打印双链接列表的第一个值,而我的程序却崩溃了
- 如何声明一个可以在整个程序中使用的全局 2d 3d 4d .. 数组(堆版本)变量?
- 我写了一个C++程序来模拟Enigma机器.我没有得到输出
- 为什么这个程序返回最后一个单词而不是最长的单词?
- 如何使用C++读取另一个程序中的源代码输出
- 我有一个对象,它将在整个程序的持续时间内实例化,但一个类成员不会,我应该动态分配它吗?
- 我的程序有一个保存配置文件的GUI,如何双击此配置文件以直接加载带有配置数据的GUI?
- 我想通过带有C++和Python的插件创建一个可扩展的应用程序
- 3-3. 编写一个程序来计算每个不同单词在其输入中出现的次数
- 为什么有时我输入一个整数,程序将第一个输入的数字打印成十进制数?
- 未定义的操作?程序一个接一个地打印出不同的值
- 如何给这个简单的 c++ 程序一个适当的循环
- 我如何给一个c++程序一个图标