【C/C++学院】0723-32位与64位/调戏窗体程序/数据分离算法/内存检索/二分查找法/myVC

【送给在路上的程序猿】

对于一个开发人员而言,能够胜任系统中随意一个模块的开发是其核心价值的体现。

对于一个架构师而言,掌握各种语言的优势并能够运用到系统中,由此简化系统的开发,是其架构生涯的第一步。

对于一个开发团队而言。能在短期内开发出用户惬意的软件系统是起核心竞争力的体现。

每个程序猿都不能固步自封,要多接触新的行业,新的技术领域,突破自我。

32位与64位

地址与内存的关系
4G = 4*1024M = 4*1024*1024k = 4*1024*1024*1024 Byte字节 = 2^32
32位,指针就是4个字节
#include <stdio.h>
void main()
{
       int num = 10;     
       printf("%p\n", &num);
       int *p = #
       printf("p=%d\n", sizeof(p));
       getchar();
}

调戏窗体程序

使用黑客工具。 spy,找到//FindWindowA參数:窗体类名。标题

#include <stdio.h>
#include<stdlib.h>
#include<Windows.h>
 
/*
窗体隐藏的时候, 能够从任务管理器中,看到此进程已经运行,使用cmd命令中的命令,把进程结束掉
C:\Users\wuyingqiang>taskkill /f /im notepad.exe
成功: 已终止进程 "notepad.exe",其 PID 为 7556。
成功: 已终止进程 "notepad.exe"。其 PID 为 1384。

成功: 已终止进程 "notepad.exe",其 PID 为 3572。 成功: 已终止进程 "notepad.exe",其 PID 为 5272。 成功: 已终止进程 "notepad.exe",其 PID 为 6212。

*/ void openCalc() { //int i=0; //for(i; i<5; i++) //{ // //system("calc"); // ShellExecuteA(0, "open", "calc", 0, 0, 1); // //第一个參数是代表系统弹出 // //第二个參数是代表运行 // //第三个參数运行命令行 // //第四个,第五个默认0, // //第六个參数,0代表窗体隐藏,1代表正常,3最大化,6最小化 // Sleep(2000); //} ShellExecuteA(0, "open", "calc", 0, 0, 1); Sleep(2000); } void closeCalc() { system("taskkill /f /im calc.exe");//结束进程 } void moveCalc() { int i=0; HWND win;//指针,返回窗体的编号 //FindWindowA參数:窗体类名。标题 win = FindWindowA("CalcFrame", "计算器");//寻找计算器 if (win == NULL) //空指针避免野指针 { printf("计算器玩失踪"); } else { printf("计算器找到"); } //控制隐藏域显示 //while (1) //{ // ShowWindow(win, SW_HIDE);//隐藏; // Sleep(2000); // ShowWindow(win, SW_SHOW);//显示; // Sleep(2000); //} //for ( i = 0; i <= 1500; i += 10) //{ // SetWindowPos(win, NULL, i, 0, 300, 400, 1);//移动窗体 // Sleep(30); //} //for对角线移动 for ( i = 0; i < 1500; i++) { SetWindowPos(win, NULL, i, i*9/16, 300, 400, 1);//移动窗体 Sleep(50); } } void main() { openCalc(); moveCalc(); Sleep(5000); closeCalc(); system("pause"); }


数据分离算法

水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身。

(比如:1^3 + 5^3+ 3^3 = 153

#include <stdio.h>
#include <stdlib.h>
void main()
{
       int i;
    for ( i = 100; i <= 999; i++)//遍历全部数据
       {
              int ge = i % 10;//取出个位
              int shi = i / 10 % 10;//取出10位
              int bai = i / 10/10;//取出百位
              //筛选
              if (ge*ge*ge + shi*shi*shi + bai*bai*bai == i)//推断条件
              {
                     printf("%d^3+%d^3+%d^3=%d\n", ge, shi, bai, i);//打印
              }
       }
    printf("\n");
       getchar();
}

内存检索

植物大战僵尸游戏中,自己主动添加阳光。找到内存地址。编写dll,使用DllInject.exe工具进行注射。

二分查找法

保证查找之前。数据是排序的。

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
  
void ShowArray(int a[], int n)
{
       for (int i = 0; i < n; i++)
       {
              printf("%d,", a[i]);
       }
       printf("\n");
}
 
void PaiXu(int a[], int n)
{
       for (int i = 0; i < n - 1; i++)
       {
              for (int j = 0; j < n - 1 - i; j++)
              {
                     if (a[j]>a[j+1])
                     {
                            int temp = a[j];
                            a[j] = a[j + 1];
                            a[j + 1] = temp;
                     }
              }
       }
}
//num为所要查找的数据,返回数组下标
int SearchFor(int a[], int n, int num)
{
       for (int tou = 0, wei = n - 1, zhong = (tou + wei) / 2; tou <= wei; zhong=(tou+wei)/2)
       {
              printf("\n開始查找%d,%d,%d", tou, wei, zhong);
              if (a[zhong] == num)
              {
                     return zhong;
              }
              else   if (a[zhong]>num)
              {
                     wei = zhong - 1;
              }
              else
              {
                     tou = zhong + 1;
              }
       }
}
 
int SearchWhile(int a[], int n, int num)
{
       int tou = 0;
       int wei = n - 1;
       int zhong = (tou + wei) / 2;
       while (tou <= wei)
       {
              printf("\n開始查找%d,%d,%d", tou, wei, zhong);
              if (a[zhong] == num)
              {
                     return zhong;
              }
              else   if (a[zhong]>num)
              {
                     wei = zhong - 1;
                     zhong = (tou + wei) / 2;
              }
              else
              {
                     tou = zhong + 1;
                     zhong = (tou + wei) / 2;
              }
       }
}
 
void main()
{
       int a[50] = { 0 };
       time_t ts;
       srand((unsigned int)time(&ts));//随机数种子
       for (int i = 0; i < 50; i++)
       {
              a[i] = rand() % 100;
              //printf("%d,", a[i]);
       }
      
       PaiXu(a, 50);
       ShowArray(a, 50);
 
       int num;
       printf("plesae input your find num:");
       scanf("%d", &num);  //扫描数据接收输入
       //int ret = SearchFor(a, 50, num);
       int ret = SearchWhile(a, 50, num);
       if (ret == -1)
       {
              printf("not find\n");
       }
       else
       {
              printf("find [%d]\n", a[ret]);
       }
       system("pause");
}


myVC

使用mfc打造自己的ide, 找到vs和codeblocks的路径中的bat批处理文件,通过单击button,使用system指令去调用这个bat批处理文件。

如D:\Program Files\Microsoft Visual Studio 11.0\Common7\Tools\ VsDevCmd.bat


|=========== 吴英强CSDN博客专栏==============|

|== C/C++学院 专栏文章的内容(不定期更新)===|

|== linux驱动开发 探索linux底层的奥秘 ==========|

|== Java基础学习篇 掌握java语言的基础知识=====|

|====== 每天进步一点点,健康快乐每一天 ========|



posted @ 2018-04-06 13:02  zhchoutai  阅读(170)  评论(0编辑  收藏  举报