![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
duh198
这个作者很懒,什么都没留下…
展开
-
c++primer plus第六版第八章编程练习
1.#include<iostream>using namespace std;int n = 0;void show(const char* a,int b=0){ n++; if (b == 0) { cout << a<<endl; } else { for (int i = 0; i < n; i++) { cout << a<<endl; } }}int main(){ cha原创 2022-04-29 22:52:38 · 946 阅读 · 0 评论 -
c++primer plus 第六版第十章编程答案(蒟蒻)
1.#include<iostream>using namespace std;class bankaccount { string name; string id; double money;public: bankaccount(const string a, const string b, double c=0.0) { name = a; id = b; money = c; }; void in() { double a; cin >> a;原创 2022-04-13 22:52:36 · 697 阅读 · 0 评论 -
c++primerplus第七章编程练习
1.#include<iostream>using namespace std;double average(double a, double b){ return (2.0 * a * b / (a + b));}int main(){ double x, y; while (cin >> x >> y) { if (x == 0 || y == 0) { cout << "end"; break; }原创 2022-03-28 23:02:32 · 1011 阅读 · 0 评论 -
今天学习c++总结
1.cin如何输入一个不符合其类型的值,会:不改变变量的值不匹配的输入被留在输入队列cin对象中一个错误标记被设置对cin方法的调用返回false(这样就可以在while等循环条件中直接使用cin输入)2.把带空格的字符串读入string对象时,getlin(cin,变量名)3.cin.clear() 重置cincin.eof() 判断是否达到EOFcin.fail() 可以检查是否到达EOF并且检查类型不匹配问题cin.good()指出最后一次读取操作是否成功4.读原创 2022-03-22 22:54:49 · 751 阅读 · 0 评论 -
c++prinmerplus第六章编程题
2.#include<fstream>#include<iostream>#include<cstdlib>#include<string>#include<cctype>#include<array>using namespace std;int main(){ double b; double sum=0.0; int count = 0; array<double,10>a; while原创 2022-03-21 22:23:44 · 1104 阅读 · 0 评论 -
cin,cin.getline(),cin.get()对于换行符(回车)的处理
cin输入后换行符留在输入队列中cin.getline(name,length)输入一行后丢弃换行符,用空字符替换换行符cin.get(name,length)输入一行后不丢弃换行符,把他留在输入队列中但是同时用cin输入时,>>会自动跳过空字符(包括换行符)...原创 2022-03-20 14:16:59 · 4062 阅读 · 0 评论