C++——循环的经典应用

client.cpp

#include  <iostream>

#include  <Windows.h>

#include <string>

using namespace std;

int main (void){

       string pwd;

      

       while (1) {

              cout << "Please input your password: ";

              cin >> pwd;

             

              if (pwd == "000123") {

                     break;

              } else {

                     cout << "Password error." << endl;

              }

       }

      

       cout << "login success" << endl;

       cout << "1. 注册" << endl;

       cout << "2. 管理" << endl;

       cout << "3. 查询" << endl;

       cout << "4. 删除" << endl;

       system("pause");

       return 0;

}

crack.cpp

#include <iostream>

using namespace std;

int main(void) {

         char pwd[7];

         char dict[64]; //10+26+26+1 = 63;

         char tmp[32];

         int index = 0;

        

         for (int i=0; i<10; i++) {

                  dict[index++] = '0' + i;

         }

        

         /*

         for (int i=0; i<26; i++) {

                  dict[index++] = 'a' + i;

         }

        

         for (int i=0; i<26; i++) {

                  dict[index++] = 'A' + i;

         }

        

         dict[index++] = '_';

         */

                          

         dict[index] = '\0';

         int n = index; // 字符个数

        

         for (int p1=0; p1<n; p1++) {

                  for (int p2=0; p2<n; p2++) {

                           for (int p3=0; p3<n; p3++) {

                                    for(int p4=0; p4<n; p4++) {

                                             for(int p5=0; p5<n; p5++){

                                                      for (int p6=0; p6<n; p6++) {

                                                               tmp[0] = dict[p1];

                                                               tmp[1] = dict[p2];

                                                               tmp[2] = dict[p3];

                                                               tmp[3] = dict[p4];

                                                               tmp[4] = dict[p5];

                                                               tmp[5] = dict[p6];

                                                               tmp[6] = '\0';

                                                               cout << tmp << endl;

                                                      }

                                             }

                                    }

                           }

                  }

         }

        

         return 0;

}

在控制台:

crack.exe  |  client.exe

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会飞的鱼-blog

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值