编写的一个字符加密程序,但是不知道为什么运行时跳过了一段cout输出
代码:
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
int main(int argc, char** argv)
{
begin:
cout << "Enter password to start this encryption program" << endl;
string Password = "A123C";
string password;
cin >> password;
if(password == Password)
cout << "Password CORRECT" << endl << endl;
else
{
cout << "ERROE, please enter again " << endl <<endl;
Sleep(1000);
goto begin;
}
cout << "Starting the encryption program "
<< "[ ]"
<< "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
for(int v;v<20;v++)
{
cout << "#";
Sleep(200);
}
cout << "\r"
<< "Program loading is completed " << endl
<< "---------------------------------------------------" << endl
<< "Enter the code you want to encrypt: ";
char a[100];
cin.get();
cin.getline(a,100);
==============运行时没有输出这一段===============
cout << "Encrypting, please wait "
<< "[ ]"
<< "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
for(int v;v<20;v++)
{
cout << "#";
Sleep(200);
}
======================================================
cout << "\r"
<< " "
<< "\nCode encrypting is completed" << endl
<< "Encrypted code is: ";
从这往下的是加密算法,不看也没关系
int i=0;
char c;
start:
c = int(int(a[i])+4), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+9), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+6), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+2), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+8), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+7), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+3), i++;
cout << c;
if(a[i] == '\0')
goto end;
else
goto start;
end:
cout << endl;
return 0;
}
代码:
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
int main(int argc, char** argv)
{
begin:
cout << "Enter password to start this encryption program" << endl;
string Password = "A123C";
string password;
cin >> password;
if(password == Password)
cout << "Password CORRECT" << endl << endl;
else
{
cout << "ERROE, please enter again " << endl <<endl;
Sleep(1000);
goto begin;
}
cout << "Starting the encryption program "
<< "[ ]"
<< "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
for(int v;v<20;v++)
{
cout << "#";
Sleep(200);
}
cout << "\r"
<< "Program loading is completed " << endl
<< "---------------------------------------------------" << endl
<< "Enter the code you want to encrypt: ";
char a[100];
cin.get();
cin.getline(a,100);
==============运行时没有输出这一段===============
cout << "Encrypting, please wait "
<< "[ ]"
<< "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
for(int v;v<20;v++)
{
cout << "#";
Sleep(200);
}
======================================================
cout << "\r"
<< " "
<< "\nCode encrypting is completed" << endl
<< "Encrypted code is: ";
从这往下的是加密算法,不看也没关系
int i=0;
char c;
start:
c = int(int(a[i])+4), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+9), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+6), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+2), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+8), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+7), i++;
cout << c;
if(a[i] == '\0')
goto end;
c = int(int(a[i])+3), i++;
cout << c;
if(a[i] == '\0')
goto end;
else
goto start;
end:
cout << endl;
return 0;
}