问题遇到的现象和发生背景
相同的代码放在不同的地方输出不同
实现加密
遇到的现象和发生背景,请写出第一个错误信息
用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
#include <iostream>
using namespace std;
int cplcode[1000];
int num[1000];
int cnt;
void complicate(int code[],const char* words,int len) {
int i = 0;
for (int j = 0; j < len; j++) {
while (*words) {
cplcode[j] = *(words++) + code[(i++) % 7];//此数组应该存的是30个数字
cout << char(cplcode[j]);
cnt++;
}
}
}
//void simplify(int code[],int len) {
// int i = 0;
// for (int j = 0; j < len; j++) {
// num[j] = cplcode[j] - code[i % 7];
// //cout << cplcode[j]<< " ";
// i++;
// }
//
//}
int main() {
int code[] = { 4,9,6,2,8,7,3 };
const char* words = "the result of 3 and 2 is not 8";
int len1 = strlen(words);
complicate(code, words,len1);
int len2 = cnt;
for (int i = 0; i < len2; i++) {
cout << cplcode[i] << " ";//但我在这里却输出的是不同的数字
}
//simplify(cplcode,len2);
return 0;
}