首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将C++代码从一个程序传输到另一个程序

将C++代码从一个程序传输到另一个程序
EN

Stack Overflow用户
提问于 2015-12-06 14:04:13
回答 2查看 57关注 0票数 0

所以,我的朋友告诉我,他成功地构建了自己的“谜机”,但他使用了一个在我的Windows版本上不起作用的程序。

昨天我安装了微软的visual,无法让他的代码在我的电脑上工作,我还很年轻,我希望这里的人能帮我。我相信问题在于库,我已经试过了所有我知道的,但是我不知道我还需要做什么,它给了我大量的错误,并且忽略了预编译的头。

下面是代码:

代码语言:javascript
复制
#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;
}

提前感谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-12-06 18:25:59

对于那些在搜索google、HEUR/QVM19.1.Malware之后来到这里的人来说,who是一个360全面安全(杀毒)假阳性。只需白名单上的VS文件夹。

我的问题在于,我的代码没有以#include "stdafx.h“开头,当它开始时,我的病毒将程序标记为恶意软件。这就是造成这一切混乱的原因。谢谢大家!

票数 0
EN

Stack Overflow用户

发布于 2015-12-06 14:07:39

首先,预编译的头包含应该是源文件中的第一行。

此外,我将在所有由"包含的标准库中分别由<>替换为开始或结束引号。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34118271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档