07 2013 档案

摘要:在C++中则把字符串封装成了一种数据类型string,可以直接声明变量并进行赋值等字符串操作。以下是C字符串和C++中string的区别:C字符串string对象(C++)所需的头文件名称或或需要头文件原因为了使用字符串函数为了使用string类声明方式char name[20];string name;初始化方式char name[20]="nihao";string name = "nihao";必须声明字符串长度么?是否使用一个null字符么?是否字符串赋值的实现方式strcpy(name,"John");name = &quo 阅读全文
posted @ 2013-07-08 13:09 hunterzhang 阅读(1245) 评论(0) 推荐(0) 编辑
摘要:#include #include #include using namespace std;int minValue(int a,int b,int c){ int min=a; if(bpAEnd) { if(pBBegin>pBEnd) return 0; else return pBEnd-pBBegin+1; } if(pBBegin>pBEnd) { if(pABegin>pAEnd) return 0; else ... 阅读全文
posted @ 2013-07-06 19:11 hunterzhang 阅读(203) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include #include using namespace std;typedef struct student{ int data; struct student *next;}node;node *head;node *creat(){ node *head,*p,*s; int x,cycle=1; head=(node *)malloc(sizeof(node)); p=head; while(cycle) { if(scanf("%d",&x)!=EOF) ... 阅读全文
posted @ 2013-07-04 15:49 hunterzhang 阅读(173) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;int main(){ int b=3; int arr[]={6,7,8,9,10}; int *ptr=arr; *(ptr++)+=123; cout<<*ptr<<' '<<*(++ptr)<<endl; return 0;}输出结果为:8 8注意:printf和cout一样都是从右到左压栈的。 阅读全文
posted @ 2013-07-02 15:51 hunterzhang 阅读(418) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;void test1(){ int a,x; for(a=0,x=0;a<=1&&!x++;a++) a++; cout<<a<<" "<<x<<endl;}void test2(){ int a,x; for(a=0,x=0;a<=1&&!x++;) a++; cout<<a<<" "<<x<<endl;}int main(){ test1(); test2 阅读全文
posted @ 2013-07-02 15:39 hunterzhang 阅读(151) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;int func(int x) //函数的关键代码{ int count=0; while(x) { x=x&(x-1); count++; } return count;}int m... 阅读全文
posted @ 2013-07-02 15:13 hunterzhang 阅读(232) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示