兰陵笑忘生
面试前找算法题目摸进了神博客!怒扩!
展开Biu

RT

又是一年校招季啊。。。。半道出家准备找实习的好忧伤

于是恶补数据结构来着=。=

嘛~摸鱼进了神博客 CSDN的(★ω★)+.*。

讲解各种经典算法和微软等公司的面试题目。

所以有需要的孩子可以去努力学术呢o(* ̄▽ ̄*)o

于是!骗回复是必须的!!!

走过路过不要错过!

戳开一次你买不了吃亏买不了上当!!!【电视广告么←_←

楼主用一生节操保证!绝对不会让泥萌失望的!!!

一生节操!!!!

本内容已隐藏,回复后刷新可见哦

[查看全文]
樱花流逝
为什么用不同的软件输出结果会不同?
展开Biu

总之问题是这样的[mw_shl_code=applescript,true]#include *本站禁止HTML标签噢*

using namespace std;

class point{

private:

int x, y;

public:

point(int a = 0, int b = 0){

x = a;

y = b;

}

point(point &p);

int getx(){

return x;

}

int gety(){

return y;

}

};

point::point(point &p){

x = p.x + 10;[mw_shl_code=applescript,true]point::point(point &p){

x = p.x + 10;

y = p.y + 20;

cout << "调用拷贝构造函数" << endl;

}

y = p.y + 20;

cout << "调用拷贝构造函数" << endl;

}

void f(point &p){

cout << p.getx() << " " << p.gety() << endl;

}

point g(){

point q(3, 5);

return q;

}

int main()

{

point p1(2, 4);

point p2(p1);

cout << p2.getx() << " " << p2.gety() << endl;

f(p2);

p2 = g();

cout << p2.getx() << " " << p2.gety() << endl;

system("pause");

return 0;

}

[/mw_shl_code]

用cb编译运行的得到的结果是这样的

而用vs2013编译得到的结果是这样的

虽然乱码也是问题。。。

但主要是为什么使用vs2013时在执行[mw_shl_code=applescript,true]p2 = g();[/mw_shl_code]时调用了

[mw_shl_code=applescript,true]point::point(point &p){

x = p.x + 10;

y = p.y + 20;

cout << "调用拷贝构造函数" << endl;

}[/mw_shl_code]

而cb没有这一步?

[查看全文]
樱花流逝
求助,关于遍历指定目录中的所有文件和子目录
展开Biu

废话不多说先上程序:

#include <stdio.h>
#include <tchar.h>
#include<io.h>
#include<stdlib.h>
#include *本站禁止HTML标签噢*
#include *本站禁止HTML标签噢*
using namespace std;
int ayu = 0;
int change_path(string path, stringnew_path){
int i = path.length();
new_path = "\\" + new_path + "*.*";
path.replace(i - 2, i, new_path);
return 0;
}
int find_file( string a )
{
string s1,s2;
long Handle;
s1.replace(NULL, NULL, a);
struct _finddata_t FileInfo;
cout << ayu << "\t" << endl;
if ((Handle = _findfirst(a.c_str(), &FileInfo)) == -1L){
if (_A_SUBDIR & FileInfo.attrib){
if ((strcmp(FileInfo.name, ".") != 0) &&(strcmp(FileInfo.name, "..") != 0)){
printf("%s\n", FileInfo.name);
s2.replace(NULL, NULL, FileInfo.name);
change_path(s1, s2);
ayu = ayu + 1;
find_file(s1);
}
}
}
else{
printf("%s\n", FileInfo.name);
while (_findnext(Handle, &FileInfo) == 0){
if (_A_SUBDIR & FileInfo.attrib){
if ((strcmp(FileInfo.name, ".") != 0) &&(strcmp(FileInfo.name, "..") != 0)){
printf("%s\n", FileInfo.name);
s2.replace(NULL, NULL, FileInfo.name);
change_path(s1, s2);
ayu = ayu + 1;
find_file(s1);
}
}
printf("%s\n", FileInfo.name);
}
_findclose(Handle);
}
ayu -= 1;
system("pause");
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
string s;
cout << "please inupt path:";
cin >> s;
find_file(s);
return 0;

}
主要思路就是通过对find_file()的递归调用来达到遍历目录的目的(ayu变量是在检错的时候加上去的)

但是实际运行的时候出来这样的错误

变量ayu显示程序在这两个文件上重复了上千次。

然而想了好久实在不知道是哪里错了orz

[查看全文]
Kimchen
小白求助 mysql建表不成 让我哭会。。。
展开Biu

这个创建表的代码是什么地方错误了 为什么不能创建哟?

创建的第一个表就OUT了。。。

数据库是MYSQL 编码是cmd.exe 代码如下:

create table db_database02(

id int auto_increment primary key,

姓名 varchar(30) not null,

年龄 int not null,

出生日期 int not null,

createtime datetime);

[查看全文]
Ti.定下契约
程序停止工作
展开Biu

本帖最后由 Ti.定下契约 于 2015-7-28 12:21 编辑

#include <stdio.h>

#include <string.h>

#define NUM 81

char input(char *array,char ch,int num);

int main(void)

{

char arr_ch[NUM],ch,*p;

gets(arr_ch);

ch=getchar();

p=input(arr_ch,ch,strlen(arr_ch));

printf("%p\n",p);

return 0;

}

char input(char *array,char ch,int num)

{

char chs[NUM],*p;

int i,j,n,x;

puts("************");

fflush(stdin);

gets(chs);

printf("%s\n",chs);

for(i=0;i<NUM;i++)

{

printf("%d,%c,%c\n",i,array[0],chs);

if(array[0]==chs)

for(j=i,n=0;n<num;j++,n++)

{

printf("%d,%c,%c\n",j,array[n],chs[j]);

if(chs[j]!=array[n])

break;

if(n==num-1)

for(x=i,n=0;n<num;x++,n++)

{

printf("%c,%c\n",ch,chs[x]);→ → → 好像是到这里程序就停止了

if(chs[x]==ch)

{

p=chs[x];

printf("%c\n",*p);

return p;

break;

}

else return '\0';

}

}

}

}

结果

array

r

************

the array

the array

0,a,t

1,a,h

2,a,e

3,a,

4,a,a

4,a,a

5,r,r

6,r,r

7,a,a

8,y,y

r,a

后面就没了@@6!!@@6!!@@6!!

[查看全文]
葉子楚
C#中的indexof()用法分享
展开Biu

IndexOf()

查找字串中指定字符或字串首次出现的位置,返首索引值,如:

str1.IndexOf("字"); //查找“字”在str1中的索引值(位置)

str1.IndexOf("字串");//查找“字串”的第一个字符在str1中的索引值(位置)

str1.IndexOf("字",start,end);//从str1第start+1个字符起,查找end个字符,查找“字”在字符串STR1中的位置[从第一个字符算起]注意:start+end不能大于str1的长度

indexof参数为string,在字符串中寻找参数字符串第一次出现的位置并返回该位置。如string s="0123dfdfdf";int i=s.indexof("df");这时i==4。

如果需要更强大的字符串解析功能应该用Regex类,使用正则表达式对字符串进行匹配。

indexof() :在字符串中从前向后定位字符和字符串;所有的返回值都是指在字符串的绝对位置,如为空则为- 1

string test="asdfjsdfjgkfasdsfsgfhgjgfjgdddd";

test.indexof(’d’) =2 //从前向后 定位 d 第一次出现的位置

test.indexof(’d’,1) =2 //从前向后 定位 d 从第三个字符串 第一次出现的位置

test.indexof(’d’,5,2) =6 //从前向后 定位 d 从第5 位开始查,查2位,即 从第5位到第7位;

lastindexof() :在字符串中从后向前定位字符和字符串;

用法和 indexof() 完全相同。

下面介绍 IndexOfAny ||lastindexofany

他们接受字符数组做为变元,其他方法同上,返回数组中任何一个字符最早出现的下标位置

如下

char[] bbv={’s’,’c’,’b’};

string abc = "acsdfgdfgchacscdsad";

Response.Write(abc.IndexOfAny(bbv))=1

Response.Write(abc.IndexOfAny(bbv, 5))=9

Response.Write(abc.IndexOfAny(bbv, 5, 3))=9

lastindexofany 同上。

====================================================================

substring() 用法

string a="aadsfdjkfgklfdglfd"

a.substring(5) //截取从第五位以后的所有字符串

a.substring(0,5) //截取从第0到第5 以后的所有字符串

摘自educast的博客

[查看全文]
aroundlight
程序白
展开Biu

露珠想要学习下编程,方向是游戏开发的,因为本身是策划,所以完全不了解,求技术摘掉大神门推荐几本书看看啊

[查看全文]
幼年技术宅
学生党暑假学游戏编程(零基础,会点C),大神求给条路...
展开Biu

RT!051~

其实人家的要求不高

只要能到2D像素游戏那个档次就行了

像rimworld什么的!26~

像我这种还有救么?

顺便蹭蹭版猪A.A

谢谢啦!!!

[查看全文]