摘要:
现在开始逐渐地学一点关于ACM的东西。慢慢地把自己的算法能力提高上去。坚持每天做几道题。都用C++解决。Love if! 阅读全文
posted @ 2014-04-10 23:59
天下纵横C++
阅读(109)
评论(0)
推荐(0)
摘要:
8.8#include using namespace std;template T SumArray(T arr[],int n){ T sum=0; for(int i=0;iT SumArray(T *arr[],int n)//arr是指向指针数组的指针{ T sum=0; for(int i=0;i<n;i++) sum+=*arr[i]; //arr[i]是一个指针,+*之后才是其中的数值; return sum;};struct debts{ char name[20]; double amount;};void main87(){ int things[6]={13,.. 阅读全文
posted @ 2014-04-10 22:33
天下纵横C++
阅读(499)
评论(0)
推荐(0)
摘要:
8.6#include #include using namespace std;template AnyType maxn(AnyType arr[],int size)//模板类{ AnyType max=arr[0]; for(int i=0;imax) max=arr[i]; } return max;};template string maxn(string arr[],int size)//具体化{ int max=0;//用于记录最大的字符串长度 int temp=0;//用于记录字符串长度 int place=0;//用于记录所在位置 for(int i=0;imax) ... 阅读全文
posted @ 2014-04-10 22:11
天下纵横C++
阅读(238)
评论(0)
推荐(0)
摘要:
8.5#include using namespace std;template AnyType max5(AnyType arr[5]){ AnyType max=0; for(int i=0;imax) max=arr[i]; } return max;};void main85(){ int a[5]={10,20,50,6,33}; double b[5]={5.2,3.5,6.7,8.8,4}; cout<<"the amax is "<<max5(a)<<endl; cout<<"the bmax is 阅读全文
posted @ 2014-04-10 21:46
天下纵横C++
阅读(204)
评论(0)
推荐(0)
摘要:
在百度知道里面得到了正确的答案http://zhidao.baidu.com/question/198940026560129285.html?quesup2&oldq=1#include#include //出问题时,使用的是cstring,但换成string一样出问题using namespace std;struct stringy{ char *str; int ct;};void set(stringy &beany,const char t[]);void show(const stringy &beany,int count=0);void show(co 阅读全文
posted @ 2014-04-10 16:34
天下纵横C++
阅读(207)
评论(0)
推荐(0)
摘要:
8.4这道题有个BUG,我暂时还是无法解决,谁解决的麻烦告诉下我#include#include //出问题时,使用的是cstring,但换成string一样出问题using namespace std;struct stringy{ char *str; int ct;};void set(stringy &beany,const char t[]);void show(const stringy &beany,int count=0);void show(const char t[],int count=0);void main84(){ stringy beany; // 阅读全文
posted @ 2014-04-10 16:17
天下纵横C++
阅读(1216)
评论(0)
推荐(0)
摘要:
8.3#include #include #includeusing namespace std;const int MAX=50;void change(string &s);void main83(){ string s="chenggSHIguang"; //char ch='\0'; change(s); while(s!="q"&&(s.length()!=1)) { cout#include //出问题时,使用的是cstring,但换成string一样出问题using namespace std;str 阅读全文
posted @ 2014-04-10 14:48
天下纵横C++
阅读(197)
评论(0)
推荐(0)
摘要:
8.2#include #include using namespace std;struct CandyBar{ char *name; double weight; int kaluli;};void set(CandyBar &cb,char *name="Millennium Munch",double weight=2.85,int kaluli=350);//默认初始化void show(const CandyBar &cb);void main82(){ CandyBar c1,c2; set(c1,"DEFU",20.5, 阅读全文
posted @ 2014-04-10 14:04
天下纵横C++
阅读(248)
评论(0)
推荐(0)
摘要:
8.1#include #include using std::cout;using std::cin;using std::endl;using std::string ;void print(const string &s,int count=0);static int number=0;//记录被调用的次数void main81(){ print("I love you"); print("Can you"); print("haha",100); print("I love you"); print 阅读全文
posted @ 2014-04-10 13:46
天下纵横C++
阅读(250)
评论(0)
推荐(0)
摘要:
7.10#include using namespace std;double add(double a,double b){return a+b;};//为了简化,这三个函数我直接在这里写了。double dev(double a,double b){return a-b;};double mul(double a,double b){return a*b;};double calculate(double a,double b,double (*pf[])(double x,double y));void main710(){ double (*pf[3])(double,double)= 阅读全文
posted @ 2014-04-10 13:23
天下纵横C++
阅读(218)
评论(0)
推荐(0)
摘要:
来试试这个功能 阅读全文
posted @ 2014-04-10 12:34
天下纵横C++
阅读(115)
评论(0)
推荐(0)
摘要:
7.9#include using namespace std;const int SLEN=30;struct student{ char fullname[SLEN]; char hobby[SLEN]; int ooplevel;};int getinfo(student pa[],int n);void display1(student st);void display2(const student *ps);void display3(const student pa[],int n);void main79(){ cout>class_size; while(cin.get( 阅读全文
posted @ 2014-04-10 12:27
天下纵横C++
阅读(362)
评论(0)
推荐(0)
摘要:
哈哈,还以为CSDN基本没人评论呢,没想到还是会有人评论的啊。虽然说是转载的文章,哈哈哈,小小的开心了一把。 阅读全文
posted @ 2014-04-10 12:07
天下纵横C++
阅读(102)
评论(0)
推荐(0)
摘要:
7.8bvs2010不知道搞毛,居然爆了一推出错。但是在Dev c++运行完成没问题,暂时还不知道为什么。已经搞清楚了错误所在。原因是:std名称空间已经有了exp这个关键词的存在!将exp改为Exp或者using namespace std改为using std::cout;using std::cin;#include using namespace std;const int Seasons=4;const char *season[Seasons]={"Spring","Summer","Fall","Winter& 阅读全文
posted @ 2014-04-10 10:47
天下纵横C++
阅读(165)
评论(0)
推荐(0)
摘要:
程序都是我在VS2010 win7 32bit情况下编译完成的。程序都是没有问题,都是我自己亲测过后可行我才发上来的。因为效率问题,题目我就无法一一发上去了。对于一些不友好的输入,程序可能会出错。说明就到这里吧。 阅读全文
posted @ 2014-04-10 10:31
天下纵横C++
阅读(186)
评论(0)
推荐(0)
摘要:
7.8a#include using namespace std;const int Seasons=4;const char *season[Seasons]={"Spring","Summer","Fall","Winter"};void fill(double *expenses);void show(const double *);void main78a(){ double expenses[Seasons]; fill(expenses); show(expenses); system("pa 阅读全文
posted @ 2014-04-10 10:28
天下纵横C++
阅读(129)
评论(0)
推荐(0)
摘要:
1.把C++当成一门新的语言学习(和C没啥关系!真的。); 2.看《ThinkingInC++》,不要看《C++变成死相》; 3.看《TheC++ProgrammingLanguage》和《InsideTheC++ObjectModel》,不要因为他们很难而我们自己是初学者所以就不看; 4.不要被VC、BCB、BC、MC、TC等词汇所迷惑——他们都是集成开发环境,而我们要学的是一门语言; 5.不要放过任何一个看上去很简单的小编程问题——他们往往并不那么简单,或者可以引伸出很多知识点; 6.会用VisualC++,并不说明你会C++; 7.学class并不难,template、STL... 阅读全文
posted @ 2014-04-10 10:09
天下纵横C++
阅读(170)
评论(0)
推荐(0)
摘要:
7.7//7.修改程序清单7.7中的3个数组处理函数,使之使用两个指针参数来表示区间.//fill_array()函数不返回实际读取了多少个数字,而是返回一个指针,该指针//指向最后被填充的位置;其他的函数可以将该指针作为第二个参数,以标识//数据结尾。#include using namespace std;double *Fill_array(double *arr);////因为是对数组进行操作,所以可以不用返回值;void const Show_array(const double *arr,double *Epoint);void Reverse_array(double *arr, 阅读全文
posted @ 2014-04-10 10:05
天下纵横C++
阅读(216)
评论(0)
推荐(0)

浙公网安备 33010602011771号