随笔分类 - C++
摘要:实现字符串翻转,思路很简单,就是首尾字符对调。 注意str<p 这里,代表指针变量的大小,因为同一个字符串的地址,str指向首字母的指针变量的值,p是指向末尾字符的指针变量的值,所有期初str一定是小于p的 后面str主键增加,p主键减少,知道中介的时候str=p;
阅读全文
摘要:第一、原理 端口扫描的原理很简单,就是建立socket通信,切换不通端口,通过connect函数,如果成功则代表端口开发者,否则端口关闭。 所有需要多socket程序熟悉,本内容是在window环境下的 第二、单线程实现方式 第三、多线程实现方式 由于单线程执行速度有些慢,我们加入多线程运行, 注意
阅读全文
摘要:很久没有学习C了,复习下,有时候觉的C特别优美,学习算法和数据结构最佳选择。
阅读全文
摘要:学习函数指针的应用 ,简单demo#include "stdafx.h"#include "SubClass.h";//函数指针typedef int (*Operation)(int a,int b);//定义int 类型函数指针typedef struct _str{ int result; O...
阅读全文
摘要:#include "stdafx.h"#include using namespace std;int main(){ char c,d,e,f; printf("please input two characters:\n"); c=getchar(); putchar...
阅读全文
摘要:#include"stdafx.h"#include<iostream>usingnamespacestd;int_tmain(intargc,_TCHAR*argv[]){chars1[60]="kingbaby";char*s2="hello";inti=0;intj=0;while(s1[i]!='\0')i++;while((s1[i]=s2[j])!='\0'){j++;i++;}cout<<s1<<endl;return0;}方法二方法二#include&
阅读全文
摘要:View Code #include"stdafx.h"#include<fstream>#include<iostream>usingnamespacestd;int_tmain(intargc,_TCHAR*argv[]){//文件写入操作/*ints=0;ofstreamfileout("a.doc");if(!fileout){cout<<"文件打开失败"<<endl;}while(s<=10){fileout<<s<<"+1="
阅读全文
摘要:View Code #include"stdafx.h"#include<iostream>#include<ctime>usingnamespacestd;voidMakecode(char*pstr,int*pkey);voidCutecode(char*pstr,int*pkey);int_tmain(intargc,_TCHAR*argv[]){intkey[]={1,2,3,4,5};//加密字符chars[]="www.xiaozhuanggushi.com";char*p=s;cout<<"加密
阅读全文
摘要:View Code #include"stdafx.h"#include<iostream>#include<ctime>usingnamespacestd;int_tmain(intargc,_TCHAR*argv[]){inta[20];srand((unsigned)time(0));//新版本的是64位,srand是32为for(inti=0;i<20;i++){a[i]=rand()%100+1;}//选择法排序(循环n-1次)思路:每一次找出适合的元素放在正确的位置上/*for(inti=0;i<19;i++){for(int
阅读全文
摘要:#include"stdafx.h"#include<iostream>usingnamespacestd;voidarith(inta){if(a%10!=0){arith(a/10);cout<<a%10;}}int_tmain(intargc,_TCHAR*argv[]){inta=486862;arith(a);intm;cin>>m;}
阅读全文
摘要:最近在学习c++,从最基础的联系这也是很常见的问题View Code #include"stdafx.h"#include<iostream>usingnamespacestd;int_tmain(intargc,_TCHAR*argv[]){intj,i;intnums=0;//质数计数ints=0;//质数之和for(i=2;i<=100;i++){boolisSushuo=true;for(j=2;j<i;j++){if(i%j==0)break;}if(j==i){//说明比i小的都循环完了nums++;s+=i;if(nums%7==0){
阅读全文