#include <iostream>
using namespace std; int main()
{
int num_1,num_2,sum=; cout << "Please enter two number: ";
cin >> num_1;
cin >> num_2; if (num_1 > num_2)
{
int a;
a = num_1;
num_1 = num_2;
num_2 = a;
} for (int i = num_1; i <= num_2; i++)
{
sum += i;
}
cout << "The sum of num_1-num_2 is " << sum << endl; system("pause");
}

  

#include <iostream>
#include <array>
using namespace std;
const int num=; int main()
{
array<long double, num+> jiecheng;
jiecheng[] = jiecheng[] = ;
cout << << "! = " << jiecheng[] << endl;
cout << << "! = " << jiecheng[] << endl;
for (int i = ; i <= num; ++i)
{
jiecheng[i] = i * jiecheng[i - ];
cout << i << "! = " << jiecheng[i]<<endl;
} system("pause");
}

#include <iostream>
#include <array>
using namespace std; int main()
{
int a,b=;
cout << "Please enter a number other than zero: ";
do
{
cin >> a;
if (a == )
cout << "Stop summing!\n";
else
{
b = b + a;
cout << "The sum of the numbers already entered is: " << b << endl;
} } while (a != );
system("pause");
}

#include <iostream>
using namespace std;
const float lixi1 = 0.1;
const float lixi2 = 0.05; int main()
{
float Daphne_i = , Cleo_i = , Daphne = Daphne_i, Cleo = Cleo_i;
int year = ; while (Daphne >= Cleo)
{
Daphne = Daphne + Daphne_i * lixi1;
Cleo = Cleo + Cleo * lixi2;
year += ;
// cout << Daphne << "," << Cleo<<"--"<< year<<endl;
}
cout << "In " << year << "th years, Cleo's funds exceed Daphne.\nAt this time, the funds of Cleo are " << Cleo << ", and the funds of Daphne are " << Daphne << ".\n";
system("pause");
}

#include <iostream>
using namespace std;
const int month = ; int main()
{
int num[month];
int sum = ;
const char* months[month] = { "January","February","March","April","May","June","July","August","September","October","November","December" }; cout << "Please enter the monthly sales volume:\n";
for (int i = ; i < month; ++i)
{
cout << months[i] << " : ";
cin >> num[i];
sum += num[i];
} cout << "The total sales this year is " << sum << ".\n"; system("pause");
}

#include <iostream>
using namespace std;
const int year = ;
const int month = ; int main()
{
int num[year][month];
int sum[] = { ,,, };
const char* months[month] = { "January","February","March","April","May","June","July","August","September","October","November","December" }; for (int j = ; j < year; ++j)
{
cout << "Please enter the monthly sales volume of " << j + << "th year:\n";
for (int i = ; i < month; ++i)
{
cout << months[i] << " : ";
cin >> num[j][i];
sum[j] += num[j][i];
}
cout << "The total sales of " << j+ << "th year is "<< sum[j] << ".\n";
sum[year] = sum[year] + sum[j];
} cout << "The total sales of " << year << " years are "<<sum[year] << ".\n"; system("pause");
}

#include <iostream>
#include <string>
using namespace std; struct car
{
string make;
int year;
}; int main()
{
int num; cout << "How many cars do you wish to catalog?";
cin >> num;
car *all_car = new car[num]; for (int i = ; i < num; ++i)
{
cout << "Car #" << i+ << endl;
cout << "Please enter the make : ";
cin.ignore();
getline(cin, all_car[i].make);
cout << "Please enter the year made : ";
cin >> all_car[i].year;
} cout << "Here is your collection:\n";
for (int i = ; i < num; ++i)
{
cout << all_car[i].year << " " << all_car[i].make << endl;
}

delete [] all_car;
system("pause");
}

#include <iostream>
#include <cstring>
using namespace std;
const int num_words = ; int main()
{
char words[];
int s = ;
bool flag = true; cout << "Enter words (to stop, tpye the word done) :\n";
for (int i = ; i < num_words; ++i)
{
cin >> words;
if (flag && !strcmp(words, "done"))
flag = false;
if (flag && strcmp(words, "done"))
s += ; } cout << "Your entered a total of " << s << " words.\n"; system("pause");
}

#include <iostream>
#include <string>
using namespace std;
const int num_words = ; int main()
{
const string sstop_word = "done";
string str;
int s = ;
bool flag = true; cout << "Enter words (to stop, tpye the word done) :\n";
for (int i = ; i < num_words; ++i)
{
cin >> str;
if (flag && str== sstop_word)
flag = false;
if (flag && !(str == sstop_word))
s += ; } cout << "Your entered a total of " << s << " words.\n"; system("pause");
}

#include <iostream>
using namespace std; int main()
{
int num;
cout << "Enter number of rows: ";
cin >> num; for (int i = ; i < num; ++i)
{
for (int j = ; j < (num - i); ++j)
cout << ".";
for (int j = ; j < i; ++j)
cout << "*";
cout << endl;
} system("pause");
}

c++ primer plus 第五章 课后题答案的更多相关文章

  1. c++ primer plus 第七章 课后题答案

    #include <iostream> using namespace std; double HAR_AVG(double, double); void TEST(bool); int ...

  2. c++ primer plus 第六章 课后题答案

    #include <iostream> #include <cctype> using namespace std; int main() { char in_put; do ...

  3. c++ primer plus 第四章 课后题答案

    #include<iostream> #include<string> using namespace std; int main() { string first_name; ...

  4. c++ primer plus 第三章 课后题答案

    #include<iostream> using namespace std; int main() { ; int shen_gao; cout <<"Please ...

  5. C程序设计(谭浩强)第五版课后题答案 第一章

    大家好,这篇文章分享了C程序设计(谭浩强)第五版课后题答案,所有程序已经测试能够正常运行,如果小伙伴发现有错误的的地方,欢迎留言告诉我,我会及时改正!感谢大家的观看!!! 1.什么是程序?什么是程序设 ...

  6. c++ primer plus 第二章 课后题答案

    #include<iostream> using namespace std; int main() { cout << "My name is Jiantong C ...

  7. python核心编程第5章课后题答案

    5-8Geometry import math def sqcube(): s = float(raw_input('enter length of one side: ')) print 'the ...

  8. python核心编程第4章课后题答案(第二版75页)

    4-1Python objects All Python objects have three attributes:type,ID,and value. All are readonly with ...

  9. python核心编程第3章课后题答案(第二版55页)

    3-4Statements Ues ; 3-5Statements Use\(unless part of a comma-separated sequence in which case \ is ...

随机推荐

  1. ac1066

    经过分析后的二分 题目是 Josnch星球是一个赌博之风盛行的星球.每个人一出生就有一定数额的钱,之后的所有收入只能由赌博获得(OMG,如果RP不好,输光了所有的 钱...)假设赌博公司的某场赌博有N ...

  2. Linux基础命令---chgrp

    chgrp 改变文件或者目录所属的群组,使用参数“--reference”,可以改变文件的群组为指定的关联文件群组. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.o ...

  3. Linux基础命令---yes

    yes 反复的输出指定的字符串,直到手动停止.此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora.   1.语法      yes [STR ...

  4. seo标题关键字描述字数限制Title,keywords,description长度最长多长 ?

    seo标题关键字描述字数限制 seo优化各个搜索引擎收录Title,keywords,description长度最长多长 ?SEO网站优化中Title标签的作用为重中之重,好的Title也就成功了一半 ...

  5. php判断数组元素是否存在某个字符串的方法

    php判断数组元素是否存在某个字符串的方法: 方法一:采用in_array(value,array,type) type 可选.如果设置该参数为 true,则检查搜索的数据与数组的值的类型是否相同. ...

  6. mybatis插入语句空值没有设置jdbcType报错

    Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: Error setti ...

  7. 学写网页 #05# CSS Mastery 笔记 1~3

    看到第四章才发现这本书已经太旧了..看到第 3 章为止吧.前三章主要讲的内容:一些编码常识.怎样选择元素.盒子模型(主要是 Margin).定位(绝对.相对.浮动.fixed 等) 第一章 conve ...

  8. linux 添加 swap

    1)在linux下,首先,查看内存和swap大小: [root@rhel6 usr]# free -m              total       used       free     sha ...

  9. troubleshooting-sqoop mysql导入hive 报:GC overhead limit exceeded

    Halting due to Out Of Memory Error...18/09/13 21:42:17 INFO mapreduce.Job: Task Id : attempt_1536756 ...

  10. Vue 父组件循环使用refs调用子组件方法出现undefined的问题

    Vue 父组件循环使用refs调用子组件方法出现undefined的问题 1. 背景 最近前端项目遇到一个问题,我在父组件中使用了两个相同的子组件child,分别设置ref为add和update.其中 ...