上一页 1 ··· 6 7 8 9 10 11 下一页
摘要: 读入一些整数,逆序输出 :#include using namespace std;int main(){ const int MAX = 100;int arr[MAX];int temp,index=0;while(cin>>temp,temp!=0)arr[index++]=temp;while(index>0)coutusing namespace std;int main(){ int n=0,k=0;//初始化n为灯 k为人的个数cin>>n>>k;int lamp[100];for(int i = 0;i!=n;++i){lamp[i]= 阅读全文
posted @ 2013-10-02 02:15 CrazyCode. 阅读(204) 评论(0) 推荐(0) 编辑
摘要: // container.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include#include#include#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ string a="in.txt"; string b="out.txt"; ifstream infile(a.c_str()); if(infile) { cout>ingood; cout<<ingood< 阅读全文
posted @ 2013-09-28 21:08 CrazyCode. 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 逗号操作符是一组由逗号分隔的表达式,这些表达死从左向右计算.逗号表达式的结果是其最后边表达式的值。如果最后边的操作数是左值,则逗号表达式的值也是左值。此类表达式通常用于for循环:int cnt=iec.size();for(vector::size_type ix=0;ix!=ivec.size();++ix,--cnt)ivec[ix]=cnt;上述的for语句在循环表达式中使ix自增1而cnt自减1。每次循环均要修改ix和cnt的值。当检验ix的条件判断成立时,程序将下一个元素重新设置为cnt的当前值.以上摘自书146面..我的理解int a(){return 1,2,3;}那么其他地方 阅读全文
posted @ 2013-09-28 20:34 CrazyCode. 阅读(174) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; void abc(int a,int b,int c) { cout<<a<<b<<c<<endl; } int main() { int i = 10; abc(i,i++,i++); return 0; }12 11 10 阅读全文
posted @ 2013-09-28 19:24 CrazyCode. 阅读(112) 评论(0) 推荐(0) 编辑
摘要: set和multiset容器的能力set和multiset容器的内部结构通常由平衡二叉树(balancedbinarytree)来实现。当元素放入容器中时,会按照一定的排序法则自动排序,默认是按照less排序规则来排序。这种自动排序的特性加速了元素查找的过程,但是也带来了一个问题:不可以直接修改set或multiset容器中的元素值,因为这样做就可能违反了元素自动排序的规则。如果你希望修改一个元素的值,必须先删除原有的元素,再插入新的元素。2set和multiset容器的操作ConstructorandDestructorsetc:创建一个空的set或multiset容器setc(op): 阅读全文
posted @ 2013-09-28 00:36 CrazyCode. 阅读(218) 评论(0) 推荐(0) 编辑
摘要: // container.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){typedef string *pstring;string a = "abc";//const pstring good = &a; 这一句和下一句的效果是一致的string *const good=&a;string b = "abcs";//good = b;re 阅读全文
posted @ 2013-09-24 03:32 CrazyCode. 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Exmpl.h/////////#pragma once#includeclass Exmpl{public://默认构造函数Exmpl(){std::cout#include#include"Exmpl.h"#include"Employee.h"using namespace std;void fun(Exmpl obj){}void fun2(Exmpl &obj){}Exmpl fun3(){Exmpl obj;return obj;}int _tmain(int argc, _TCHAR* argv[]){//Exmpl a;//这里调 阅读全文
posted @ 2013-09-24 03:27 CrazyCode. 阅读(184) 评论(0) 推荐(0) 编辑
摘要: // container.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){char ca1[]={'1','2','3'};cout<<sizeof(ca1)/sizeof(char)<<endl;//输出3char ca2[]="123";cout<<sizeof(ca2)/s 阅读全文
posted @ 2013-09-24 03:25 CrazyCode. 阅读(159) 评论(0) 推荐(0) 编辑
摘要: char *words[]={"abbc","plump","buck","mulligan"}这里其实是定义了一个指针数组.顺序容器的元素排列次序与元素值无关,而是由元素添加到容器中的次序决定的.顺序容器:vector list deque顺序容器适配器 stack 后进先出LIFO栈 queue 先进先出FIFO队列. priority_queue有优先级管理的队列.将一个容器复制给另一个容器时,类型必须匹配:容器类型和元素类型都必须相同.接受容器大小做形参的构造函数只适用于顺序容器,而关联容器不支持这种初始化 阅读全文
posted @ 2013-09-02 03:10 CrazyCode. 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 用数组的长度去除以数组里面数据类型的长度.就能求出数组里面的元素的个数.int ia[]={0,1,1,2,3,5,8,13,21,55,89};int count = sizeof(ia)/ sizeof(ia[0]); 阅读全文
posted @ 2013-09-02 02:40 CrazyCode. 阅读(237) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 下一页