02 2020 档案
摘要:一、复习题 6.为什么不对基本数据类型的函数参数使用const? 将const限定符用于指针,以防止指向的原始数据被修改,程序传递基本类型(int或double)时,将按值传递,以便函数使用副本,这样,原始数据将得到保护。 8.编写一个函数,将字符串中所有c1替换成c2,并返回替换次数。 1 #in
阅读全文
摘要:程序清单7.7中的一部分 转自https://blog.csdn.net/lancert9/article/details/43410811 使用 if(!cin) 对输入的参数进行相应数据类型的判断,对于初学者来说具有很大的引用力。但是,在使用 if(!cin) 做出判断时,可能会遇到一些奇特的问
阅读全文
摘要:1. 编写一个程序,读取键盘输入,直到遇到@符号为止,并回显输入(除数字外),同时将大写字符转换为小写字符,将小写字符转换为大写(别忘了cctype函数系列) 1 #include<iostream> 2 using namespace std; 3 4 int main() 5 { 6 char
阅读全文
摘要:程序清单6.15(写入到文本文件中) 1 #include<iostream> 2 #include<fstream> 3 using namespace std; 4 5 int main() 6 { 7 char automobile[50]; 8 int year; 9 double a_pr
阅读全文
摘要:1.编写一个要求用户输入两个整数的程序,将程序将计算并输出这两个整数之间(包括这两个整数)所有的整数的和。这里假设先输入较小的整数,例如如果用户输入的是2和9,则程序将指出2-9之间所有整数的和为44. 1 #include<iostream> 2 using namespace std; 3 4
阅读全文
摘要:程序5.14(延时等待) 1 #include<iostream> 2 #include<ctime> 3 using namespace std; 4 5 void main() { 6 cout << "Enter the delay time,in seconds:"; 7 float sec
阅读全文
摘要:1.编写一个 c++ 程序,如下述输出示例所示的那样请求并显示信息 : What is your first name? Betty SueWhat is your last name? YeweWhat letter grade do you deserve? BWhat is your age?
阅读全文
摘要:1 . 编写一个小程序,要求用户使用一个整数输出自己的身高(单位为厘米),然后将身高转换为米和厘米。该程序使用下划线字符来指示输入位置。另外,使用一个 const 符号常量来表示转换因子。 1 #include<iostream> 2 using namespace std; 3 4 int mai
阅读全文

浙公网安备 33010602011771号