可视化地将C++代码从一个程序转移到另一个程序

visual transfering C++ code from one programme to another

本文关键字:程序 一个 转移 另一个 C++ 代码 可视化      更新时间:2023-10-16

所以,我的朋友告诉我,他成功地构建了自己的"谜机",但他使用的程序在我的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"开头的,当它开始时,我的病毒会将程序标记为恶意软件。这就是造成这一切混乱的原因。谢谢大家!

相关文章: