
C++ Primer Plus
文章平均质量分 59
李子树下mini
这个作者很懒,什么都没留下…
展开
-
leetcode 刷题
leetcode刷题原创 2023-02-26 18:33:41 · 165 阅读 · 1 评论 -
C++ Primer Plus 第七章之编程练习题
7.1 计算调和平均数#include<iostream>using namespace std;double cal(int x,int y);int main(){ int x,y; double ave; while(1){ cout << "Please enter two number:"; cin>>x>>y; ...原创 2020-01-28 12:23:49 · 485 阅读 · 0 评论 -
C++ Primer Plus 第七章之知识梳理
数组函数为将数组类型和元素数量告诉数组处理函数,要通过两个不同的参数来传递它们,而不要试图用方括号表示法来传递数组长度。数组名被视为地址,相应的形参是一个指针。void fillArray(int arr[],int size);//正确形式void fillArray(int arr[size]);//不可取const与指针(1)const int *p;此时const修饰的是 ...原创 2020-01-28 10:58:25 · 203 阅读 · 0 评论 -
C++ Primer Plus 第六章之编程练习题
6.1 字符转换#include<iostream>#include<cctype>using namespace std;int main(){ char ch; cin.get(ch); while(ch!='@'){ if(islower(ch)) ch = toupper(ch); else if(isupper(ch)) ch =...原创 2020-01-27 21:21:00 · 401 阅读 · 0 评论 -
C++ Primer Plus 第六章之知识梳理
1. ++ch和ch+1的区别#include<iostream>using namespace std;int main(){ char ch; cin.get(ch); while(ch!='.') { if(ch=='\n') cout<<ch; else// cout<<++ch; cout<<ch+1...原创 2020-01-25 23:23:29 · 123 阅读 · 0 评论 -
【学】C++ Primer Plus之判断字符空格及个数
1.字符读入,以’.'为结尾#include<iostream>#include<cstring>using namespace std;int main(){ int sum =0; int total = 0; char ch; cin.get(ch); while(ch!='.') { if(ch==' ') total++; sum...原创 2020-01-25 21:13:03 · 786 阅读 · 0 评论 -
C++ Primer Plus 第五章之编程练习题
5.1 两整数之间的和#include<iostream>using namespace std;int main(){ int i,j; cin>>i>>j; int sum = 0; for (int k=i;k<=j;k++) { sum+=k; } cout<<"sum : "<<sum; ret...原创 2020-01-25 20:53:04 · 256 阅读 · 1 评论 -
C++ Primer Plus 第五章之知识梳理
1.逗号运算符花絮cata = 17,240;被解释为(cata = 17),240;cata = (17,240);被解释为cata = 240;2.for循环体里的字符串#include<iostream>#include<cstring>//提供了strcmp()函数原型 using namespace std;int main(){ ch...原创 2020-01-25 15:14:20 · 317 阅读 · 0 评论 -
C++ Primer Plus 第四章之编程练习题
4.1按要求显示信息#include<iostream>#include<string> using namespace std;int main(){ string fname,lname; char grade; int age; cout<<"What is your first name?"; getline(cin,fname); ...原创 2020-01-23 22:05:37 · 490 阅读 · 0 评论 -
C++ Primer Plus 第四章之知识梳理
4.1数组需要声明数组的类型,数组名,数组中的元素数。下标从0开始,注意有效下标值的重要性。数组的初始化int hand[4];hand[4] = {5,6,7,7};//不允许int cost[4] = {1,2,3,4};//可以hand = cost;//不允许long hands[100] = {0};//将全部元素都赋值为0如果只对数组的一部分进行赋值,则其他剩下...原创 2020-01-23 14:47:42 · 194 阅读 · 0 评论 -
C++ Primer Plus 第三章之编程练习题
概要这一章的编程练习题主要考察不同数据类型的运用(在什么时候用什么样的数据类型比较好)以及类型转换(定义数据类型跟实际计算的时候所需的类型不一样)3.1英尺和英寸表示身高#include<iostream>using namespace std;int main(){ const float changeFactor = 12.0; //输入身高 int n_tall;...原创 2020-01-19 16:50:41 · 354 阅读 · 0 评论 -
C++ Primer Plus 第三章之知识梳理
1.变量命名习惯一些约定的用前缀来表示变量类型或内容的前缀n---------------表示整型变量str或者sz-------表示以空字符结束的字符串b---------------表示布尔值p---------------表示指针c---------------表示单个字符...原创 2020-01-19 14:28:22 · 211 阅读 · 0 评论 -
C++ Primer Plus 第二章之编程练习题
2.1 显示姓名和地址#include<iostream>using namespace std;int main(){ cout<<"姓名:小明 地址:中国"<<endl; return 0;} 2.2 以long为单位进行220码的转换在这里插入代码片...原创 2020-01-18 09:35:30 · 224 阅读 · 0 评论