欢迎来到天天文库
浏览记录
ID:36982325
大小:30.37 KB
页数:7页
时间:2019-05-02
《森实验报告林.docx》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验二:c++函数及作用域一、实验目的:1、理解程序设计的模块性概念2、掌握C++函数命名的格式3、进一步熟悉VisualC++6.0或BC3.1编辑器,程序调试环境锻炼调试程序、排除程序错误的能力4、了解作用域的内涵及::的用法二、实验环境:vc6三、试验题目1.求∑i!(i为一个变量n)#includevoidmain(){intsum(0),n(1);for(inti=1;i<=10;i++){n*=i;sum+=n;}cout<2、二次方程的解,。讨论下述情况:(1)b*b-4*a*c=0,有两个相等实根;(2)b*b-4*a*c>0,有两个不相等实根;(3)b*b-4*a*c<0,有两个共轭复根;(4)a=0,不是二次方程。#include#includevoidmain(){doublea,b,c,m,x1,x2,realpart,imagpart;cout<<"输入a,b,c:"<>a>>b>>c;if(fabs(a)<=1e-6)cout<<"不是二次方程"3、<0){x1=(-b+sqrt(m))/(2*a);x2=(-b-sqrt(m))/(2*a);cout<<"两个不同的根"<4、=sqrt(-m)/(2*a);cout<<"有两个共轭复根"<5、*************************#includevoidmain(){for(inti=0;i<=3;i++){for(intj=0;j<=2-i;j++)cout<<"";for(intk=0;k<=2*i;k++)cout<<"*";for(intm=0;m<=2-i;m++)cout<<"";cout<6、-p);k++)cout<<"*";for(intm=0;m<=p;m++)cout<<"";cout<7、lude#includestructprolist{charname[20];intnum,innum,outnum;floatinprice,outprice;doublediscount;chartime[10];prolist*next;};//建立链表voidcreat(prolist*lst,charname[20],intnum,intinnum,intoutnum,floatinprice,floatoutprice,chartime[108、],doublediscount){if(lst==NULL)return;prolist*p=newprolist;strcpy(p->name,name);p->num=num;p->innum=innum;p->outnum=outnum;p->inprice=inprice;p->outprice=outprice;p->discount=discount;strcpy(p->time,time);p->next=lst->next;lst->next=p;}//对产品的变
2、二次方程的解,。讨论下述情况:(1)b*b-4*a*c=0,有两个相等实根;(2)b*b-4*a*c>0,有两个不相等实根;(3)b*b-4*a*c<0,有两个共轭复根;(4)a=0,不是二次方程。#include#includevoidmain(){doublea,b,c,m,x1,x2,realpart,imagpart;cout<<"输入a,b,c:"<>a>>b>>c;if(fabs(a)<=1e-6)cout<<"不是二次方程"
3、<0){x1=(-b+sqrt(m))/(2*a);x2=(-b-sqrt(m))/(2*a);cout<<"两个不同的根"<4、=sqrt(-m)/(2*a);cout<<"有两个共轭复根"<5、*************************#includevoidmain(){for(inti=0;i<=3;i++){for(intj=0;j<=2-i;j++)cout<<"";for(intk=0;k<=2*i;k++)cout<<"*";for(intm=0;m<=2-i;m++)cout<<"";cout<6、-p);k++)cout<<"*";for(intm=0;m<=p;m++)cout<<"";cout<7、lude#includestructprolist{charname[20];intnum,innum,outnum;floatinprice,outprice;doublediscount;chartime[10];prolist*next;};//建立链表voidcreat(prolist*lst,charname[20],intnum,intinnum,intoutnum,floatinprice,floatoutprice,chartime[108、],doublediscount){if(lst==NULL)return;prolist*p=newprolist;strcpy(p->name,name);p->num=num;p->innum=innum;p->outnum=outnum;p->inprice=inprice;p->outprice=outprice;p->discount=discount;strcpy(p->time,time);p->next=lst->next;lst->next=p;}//对产品的变
4、=sqrt(-m)/(2*a);cout<<"有两个共轭复根"<5、*************************#includevoidmain(){for(inti=0;i<=3;i++){for(intj=0;j<=2-i;j++)cout<<"";for(intk=0;k<=2*i;k++)cout<<"*";for(intm=0;m<=2-i;m++)cout<<"";cout<6、-p);k++)cout<<"*";for(intm=0;m<=p;m++)cout<<"";cout<7、lude#includestructprolist{charname[20];intnum,innum,outnum;floatinprice,outprice;doublediscount;chartime[10];prolist*next;};//建立链表voidcreat(prolist*lst,charname[20],intnum,intinnum,intoutnum,floatinprice,floatoutprice,chartime[108、],doublediscount){if(lst==NULL)return;prolist*p=newprolist;strcpy(p->name,name);p->num=num;p->innum=innum;p->outnum=outnum;p->inprice=inprice;p->outprice=outprice;p->discount=discount;strcpy(p->time,time);p->next=lst->next;lst->next=p;}//对产品的变
5、*************************#includevoidmain(){for(inti=0;i<=3;i++){for(intj=0;j<=2-i;j++)cout<<"";for(intk=0;k<=2*i;k++)cout<<"*";for(intm=0;m<=2-i;m++)cout<<"";cout<6、-p);k++)cout<<"*";for(intm=0;m<=p;m++)cout<<"";cout<7、lude#includestructprolist{charname[20];intnum,innum,outnum;floatinprice,outprice;doublediscount;chartime[10];prolist*next;};//建立链表voidcreat(prolist*lst,charname[20],intnum,intinnum,intoutnum,floatinprice,floatoutprice,chartime[108、],doublediscount){if(lst==NULL)return;prolist*p=newprolist;strcpy(p->name,name);p->num=num;p->innum=innum;p->outnum=outnum;p->inprice=inprice;p->outprice=outprice;p->discount=discount;strcpy(p->time,time);p->next=lst->next;lst->next=p;}//对产品的变
6、-p);k++)cout<<"*";for(intm=0;m<=p;m++)cout<<"";cout<7、lude#includestructprolist{charname[20];intnum,innum,outnum;floatinprice,outprice;doublediscount;chartime[10];prolist*next;};//建立链表voidcreat(prolist*lst,charname[20],intnum,intinnum,intoutnum,floatinprice,floatoutprice,chartime[108、],doublediscount){if(lst==NULL)return;prolist*p=newprolist;strcpy(p->name,name);p->num=num;p->innum=innum;p->outnum=outnum;p->inprice=inprice;p->outprice=outprice;p->discount=discount;strcpy(p->time,time);p->next=lst->next;lst->next=p;}//对产品的变
7、lude#includestructprolist{charname[20];intnum,innum,outnum;floatinprice,outprice;doublediscount;chartime[10];prolist*next;};//建立链表voidcreat(prolist*lst,charname[20],intnum,intinnum,intoutnum,floatinprice,floatoutprice,chartime[10
8、],doublediscount){if(lst==NULL)return;prolist*p=newprolist;strcpy(p->name,name);p->num=num;p->innum=innum;p->outnum=outnum;p->inprice=inprice;p->outprice=outprice;p->discount=discount;strcpy(p->time,time);p->next=lst->next;lst->next=p;}//对产品的变
此文档下载收益归作者所有