cprimerplus第六版课后编程练习答案

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
cout<<"success3:"<<success[2]<<endl;
doubleaverage=(success[0]+success[1]+success[2])/3;
cout<<"average:"<<average<<endl;
retuBiblioteka Baidun0;
}
array—方法2
#include<iostream>
cout<<endl;
}
return0;
}
for(inti=0;i<num;++i)
{
cout<<"Car#"<<i+1<<":\n";
cout<<"Pleaseenterthemake:";
getline(cin,ps[i].name);
cout<<"Pleaseentertheyearmade:";
(cin>>ps[i].year).get();
intmain()
{
usingnamespacestd;
cout<<"Enternumberofrows:";
intnum;
cin>>num;
for(inti=0;i<num;i++)
{
for(intj=num-i;j>1;j--)
cout<<".";
for(intk=0;k<=i;++k)
cout<<"*";
#include<array>
intmain()
{
usingnamespacestd;
array<double,4>ad={0};
cout<<"Enteryoursuccessofthethreetimes40metersrunning:\n";
cin>>ad[0]>>ad[1]>>ad[2];
cout<<"success1:"<<ad[0]<<endl;
cout<<"Enteryoursuccessofthethreetimes40metersrunning:\n";
cin>>success[0]>>success[1]>>success[2];
cout<<"success1:"<<success[0]<<endl;
cout<<"success2:"<<success[1]<<endl;
Europeanstyle(litersper100kilometers):
耗油量--美国风格(mpg)转换成欧洲风格(L/100Km)
#include<iostream>
intmain()
{
usingnamespacestd;
cout<<"Entertheautomobilegasolineconsumptionfigurein\n"
}
cout<<"Hereisyourcollection:\n";
for(inti=0;i<num;++i)
cout<<ps[i].year<<""<<ps[i].name<<endl;
delete[]ps;
return0;
}
n";
return0;
}
n";
return0;
}
#include<iostream>
第二章:开始学习C++
n”;
}
<<endl;
return0;
}
doubleC2F(doublet)
{
*t+32;
}
<<endl;
return0;
}
doubleconvert(doublet)
{
return63240*t;n";
return0;
}
Entertheautomobilegasolineconsumptionfigurein
cout<<"success2:"<<ad[1]<<endl;
cout<<"success3:"<<ad[2]<<endl;
ad[3]=(ad[0]+ad[1]+ad[2])/3;
cout<<"average:"<<ad[3]<<endl;
return0;
}
第五章循环和关系表达式
et();
car*ps=newcar[num];
}
rand<<endl
<<snack[i].weight<<endl
<<snack[i].calory<<endl<<endl;
}
return0;
}
rand="A";eight=;
snack[0].calory=200;
snack[1].brand="B";
snack[1].weight=;
snack[1].calory=400;
<<"";
doubleUS_style;
cin>>US_style;
cout<<"ConvertstoEuropeanstyle(milespergallon):"<<endl;
cout<<US_style<<"mpg="<<*US_style<<"L/100Km\n";
return0;
}
n";
return0;
snack[2].brand="C";
snack[2].weight=;
snack[2].calory=500;
for(inti=0;i<3;i++)
{
cout<<"brand:"<<snack[i].brand<<endl;
cout<<"weight:"<<snack[i].weight<<endl;
cout<<"calorie:"<<snack[i].calory<<endl<<endl;
}
delete[]snack;
return0;
}
数组—方法1
#include<iostream>
intmain()
{
usingnamespacestd;
constintSize=3;
intsuccess[Size];
相关文档
最新文档