![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++学习之路
文章平均质量分 56
huang12315
这个作者很懒,什么都没留下…
展开
-
局部变量问题
<br />#include <iostream>using namespace std;int *pPoint;void Func(){ int Number; Number=25; pPoint=&Number;}void UseStack(){ int a=10;}int main(){ Func(); cout<<*pPoint<<endl; UseStack(); cout<<*pPoint<<endl; co原创 2011-05-17 22:07:00 · 486 阅读 · 0 评论 -
字符串翻转和单词倒转
void Reverse(char* begin, char* end){ while (begin < end) { char temp = *begin; *begin++ = *end; *end--=temp; }}int main(){ c原创 2011-09-07 22:42:06 · 568 阅读 · 0 评论 -
c++返回函数局部对象的引用
<br />class Node{public: double a; int b; char c; Node(double a=0,int b=0,char c=0) { this->a=a; this->b=b; this->c=c; } //拷贝构造函数 //Node(const Node &n) //{ // a=n.a; // b=n.b; // c=n.c; //}};Node& Get原创 2011-05-01 23:10:00 · 2472 阅读 · 1 评论 -
汉诺塔(递归算法)
void move(int n,char getone,char putone){ cout"0) { Hanoi(n-1,A,C,B);//借B,将n-1个A移动到C move(n,A,B);//输出A移动到B的路径 Hanoi(n-1,C,B,A);//借A,将n-1个盘从C移动到B }}int main(){ int m; cin>>m; Hanoi(m,'A','B','C'); return 0;}原创 2011-04-30 17:02:00 · 975 阅读 · 0 评论 -
串中字符出现的次数
int main(){ char *str="aabcaadeegfssdjfekfajfbewf"; int cout_array[256]={0}; //遍历每个字符,将每个字符作为cout_array的index,即直接由数组自己去判断 //字符是否相等,如果是同一个字符就自动++ for (int str_index=0;str_index0) { cout原创 2011-04-30 16:01:00 · 402 阅读 · 0 评论 -
最大子段和问题
int max_value(int array[],int size,int &begin,int &end){ int maxvalue=0;//用于保存当前数组的最大值 int array_temp=0;//用于保存数组当前的值 int temp_begin,temp_end; for (int array_index=0;array_index0) { array_temp+=array[array_index]; temp_end=array_index;原创 2011-04-30 15:41:00 · 383 阅读 · 0 评论 -
mysql不能创建奇数个中文字的表
create table 工( 工作编号 char(8) not null, 最低工资 int, 最高工资 int)[Err] 1005 - Can't create table '工' (errno: 22)[SQL] create table 工作表( 工作编号 char(8) not null, 最低工资 int, 最高工资 int)[Err] 1005 - Can't create table '工作表' (errno: 22)[SQL] create table 工作( 工作编号 char(8)原创 2011-04-24 16:42:00 · 620 阅读 · 0 评论 -
最大公约数-欧几里
<br />int gcd(int a,int b){ while (b!=0) { a=a%b; int temp=a; a=b; b=temp; } return a;}<br />即两个数中大的与小的求模,然后交换,直到余数为零……原创 2011-05-29 23:17:00 · 584 阅读 · 0 评论 -
螺旋方阵
#include using namespace std;void Matric(int **array,int row,int col,bool isClock){ int indexRow,indexCol=indexRow=0; //用于判断是否顺时针还是逆时针,1为顺时针 int dir=(isClock==true)?1:-1; int s=1; //第一个先赋值为1 array[indexRow][indexCol]=s; int rowDir=0;原创 2011-05-29 15:55:00 · 495 阅读 · 0 评论 -
引以为鉴……
<br />今天去网龙面试,原以为会有面试,一到那,主管就直接给我们5个人出了一题,什么都没有,给了张纸和笔就开始答题,也没说时间什么的。一看到题目,晕了,昨晚学长说了他当时去面试时的题目,也只是说了个大概,当时没在意。谁想到今天去那就碰到这题,悲剧了,加上紧张,脑袋一片空白,最终悲剧了。<br />从今天面试得到一个结论:以后主管给题的时候,先想能解决的方案,而不要去想那些时间复杂度什么的,因为根本没那么多的时间,除非自己有很大的把握。在写代码的时候要充分利用时间。不然时间可能不够,主管不可能有那么多时间原创 2011-05-27 21:41:00 · 583 阅读 · 0 评论 -
再续虚函数……
1、每个含有虚函数的类都含有一个虚指针和一个虚函数表,当sizeof求类的内存大小分配的时候,会计算上虚指针的大小(指针的大小就是4个字节)。虚指针存放在栈中,用于指向存在于常量区的虚函数表。#include using namespace std;class Base{ int i;public: Base() { i=1; } virtual void f1() { cout原创 2011-05-26 11:48:00 · 437 阅读 · 0 评论 -
c++不能被继承的类
<br />思路:由于任何派生类的对象在创建的时候,都必然会调用其所有祖先类的构造函数,所以,只要这些构造函数中任何一个无法访问,就可以阻止该派生类对象的构造。<br />1、将类的构造函数定义为私有的,同时在该类中定义一个公有的的静态成员函数,由这个函数来完成对象的初始化工作。(单件类就是通过这种方式实现的)<br />class FinalClass{private: FinalClass() { } int num;public: static FinalC原创 2011-04-04 11:04:00 · 544 阅读 · 0 评论 -
解析字符串中的数字,并将其排序后输出字符串
题目:任意一串字符串 字符串里包含数字部分和一般的字符例如 ad2ef35adx1wewe76注意这个字符串 里面有4个数字 分别是 1 2 35 76 不考虑大数将数字按照从小到大排序 组成一个新的字符串要求制作一个函数来进行处理假设是原创 2011-09-19 16:54:35 · 1791 阅读 · 0 评论