- 博客(178)
- 收藏
- 关注
原创 习题6-1 分类统计字符个数 (15 分)(答案)
本题要求实现一个函数,统计给定字符串中英文字母、空格或回车、数字字符和其他字符的个数。函数接口定义:void StringCount( char s[] );其中 char s[] 是用户传入的字符串。函数StringCount须在一行内按照letter = 英文字母个数, blank = 空格或回车个数, digit = 数字字符个数, other = 其他字符个数的...
2019-11-30 09:14:07
5928
1
原创 习题5-6 使用函数输出水仙花数 (20 分)答案
水仙花数是指一个N位正整数(N≥3),它的每个位上的数字的N次幂之和等于它本身。例如:153=13+53+33。 本题要求编写两个函数,一个判断给定整数是否水仙花数,另一个按从小到大的顺序打印出给定区间(m,n)内所有的水仙花数。函数接口定义:int narcissistic( int number );void PrintN( int m, int n );...
2019-10-20 18:23:45
5406
1
原创 习题5-5 使用函数统计指定数字的个数 (15 分)答案
本题要求实现一个统计整数中指定数字的个数的简单函数。函数接口定义:int CountDigit( int number, int digit );其中number是不超过长整型的整数,digit为[0, 9]区间内的整数。函数CountDigit应返回number中digit出现的次数。#include<stdio.h>#include<math.h...
2019-10-17 11:46:35
3884
原创 习题5-4 使用函数求素数和 (20 分)答案
本题要求实现一个判断素数的简单函数、以及利用该函数计算给定区间内素数和的函数。素数就是只能被1和自身整除的正整数。注意:1不是素数,2是素数。函数接口定义:int prime( int p );int PrimeSum( int m, int n );其中函数prime当用户传入参数p为素数时返回1,否则返回0;函数PrimeSum返回区间[m, n]内所有素数的和。题目保证...
2019-10-16 23:03:22
11406
3
原创 习题5-3 使用函数计算两点间的距离 (10 分)答案
本题要求实现一个函数,对给定平面任意两点坐标(x1,y1)和(x2,y2),求这两点之间的距离。函数接口定义:double dist( double x1, double y1, double x2, double y2 );其中用户传入的参数为平面上两个点的坐标(x1, y1)和(x2, y2),函数dist应返回两点间的距离。#include...
2019-10-16 21:17:36
5105
原创 习题5-2 使用函数求奇数和 (15 分)答案
本题要求实现一个函数,计算N个整数中所有奇数的和,同时实现一个判断奇偶性的函数。函数接口定义:int even( int n );int OddSum( int List[], int N );其中函数even将根据用户传入的参数n的奇偶性返回相应值:当n为偶数时返回1,否则返回0。函数OddSum负责计算并返回传入的N个整数List[]中所有奇数的和。#includ...
2019-10-16 11:38:42
2328
1
原创 习题5-1 符号函数 (10 分)答案
本题要求实现符号函数sign(x)。函数接口定义:int sign( int x );其中x是用户传入的整型参数。符号函数的定义为:若x大于0,sign(x) = 1;若x等于0,sign(x) = 0;否则,sign(x) = −1。#include<stdio.h>int sign(int x){ if (x > 0) { retur...
2019-10-16 09:24:15
2765
原创 练习5-3 数字金字塔 (15 分)答案
本题要求实现函数输出n行数字金字塔。函数接口定义:void pyramid( int n );其中n是用户传入的参数,为[1, 9]的正整数。要求函数按照如样例所示的格式打印出n行数字金字塔。注意每个数字后面跟一个空格。#include<stdio.h>void pyramid(int n){ for (int i = 1; i < ...
2019-10-15 14:29:50
3158
原创 练习5-2 找两个数中最大者 (10 分)(答案)
本题要求对两个整数a和b,输出其中较大的数。#include<stdio.h>int max(int a, int b){ if (a > b) { return a; } else { return b; }}void main(){ int a = 0; int b = 0; scanf_s("%d %d", &a, &...
2019-10-15 09:57:51
2043
原创 练习5-1 求m到n之和 (10 分) 答案(递归法)
本题要求实现一个计算m~n(m<n)之间所有整数的和的简单函数。#include<stdio.h>int sum(int m, int n){ if (m == (n-1)) { return (2 * m + 1); } else { return sum(m, (n - 1)) + n; }}void main(){...
2019-10-14 17:33:34
1207
转载 Name Completion
Name CompletionWhen you are typing command lines to CMD, you often need to type file and folder names. Name completion makes this easier-you can type just the first few letters of a file or folder n...
2019-03-04 17:29:40
410
转载 数组与指针的艺术--深入探索c/c++数组与指针的奥秘
转载转载转载转载转载转载转载转载转载转载转载转载转载转载转载http://topic.youkuaiyun.com/u/20091123/11/0c03d2e2-0655-4634-8287-0e2315d889fc.html?8345 前 言 此文是笔者2005年所作《再再论指针》的修订版,与前文相比,本文主要的不同点有如下几点: 一、引用C/C++标准的条款去阐述原理。C与C++标准共有四个已发行的正...
2018-03-23 11:06:10
649
原创 棋盘游戏实例
#include#includechar matrix[3][3];char check(void);void init_matrix(void);void get_player_move(void);void get_computer_move(void);void disp_matrix(void);int main(void){ char done; print
2018-01-27 16:14:58
1155
原创 edius 输出问题:无法使用选择的格式
edius使用过程中经常会遇到一个问题,素材可以正常导入编辑,输出的时候却跳出“无法使用选择的格式,请调整设置”的错误,网页上全是些胡扯的答案。正确做法是:在输出设置中(以H264为例),有一个输出音频选框,取消掉音频输出后,如果能正常输出,说明是音频输出设置有问题,将其调整为48kHz2H即可。
2018-01-16 10:26:38
10691
4
原创 accelerated c++ 练习2-2
#include#includeusing namespace std;int main(){ //ask for person's name cout << "Please enter your name: "; string name; cin >> name; //build the message that we intend to write const s
2017-12-10 12:03:20
1024
原创 accelerated 2-5-4
#include #include using namespace std;//say what standard-libary names we useusing std::cin;using std::cout;int main(){ //ask for person's name cout << "Please enter your name: "; //read
2017-12-04 17:02:08
251
原创 accelerated c++ 1.2
#include#includeint main(){ std::cout << "Please enter your first name: "; std::string name; std::cin >> name; const std::string greeting = "Hello, " + name + "!"; const std::string spaces
2017-11-27 15:02:52
221
原创 accelerated c++ 0-2
#include int main(){ std::cout << "This (\") is a quote, and this (\\) is a backslash" << std::endl; return 0;}
2017-11-24 14:25:56
302
原创 指针测试
#includeusing namespace std;int main(){ int *pInt = NULL; cout << "指针变量pInt地址是:" << &pInt << endl; int para = 1; cout << "para地址是:"<< ¶ << endl; cout << "para值是:"<< para << endl; pInt = ¶
2017-09-08 13:41:08
381
原创 用玩游戏的技巧来解决工作问题
今天碰到个麻烦事,2400多个视频片段要更换片头片尾,长度不同,输出路径不同,面对如此恶心的烂事,忽然想到当年玩网游经常用的按键精灵,事情完美解决,纪念一下。
2017-08-18 17:27:00
268
转载 20个流行无线工具
去年,我写了一篇文章,介绍流行的无线黑客工具来破解或恢复无线网络的密码。在这篇文章中,我们新添加了13个工具,这些工具很受欢迎,效果很棒。我把帖子更新一下,添加上去。 我不会解释无线安全和WPA / WEP。您可以通过阅读有关无线黑客工具的现有文章,来了解它们。在这篇文章中,我会更新现有的列表,添加更多强大的工具。我在现有列表中新加了七个工具,为您提供了最常用的无线破解工具列表。
2017-07-25 16:35:07
4094
原创 《托马斯大学微积分》习题1.4——31
《托马斯大学微积分》习题1.4——31题:磷-32的半衰期约为14天,一开始有6.6克.1)写出磷-32的残余量关于时间x的函数2)什么时候只剩下1克磷-32了?网上答案个人觉得有误,估计没看过这本书。
2017-07-24 16:48:35
1188
原创 练习1-15 重写温度转换程序
#includeint tempreture(int);int fahr, cesius;main(){ int lower, upper, step; lower = 0; upper = 300; step = 20; while (fahr <= upper) { cesius = tempreture(fahr); printf("%d\t%d\n",
2017-07-12 16:58:50
614
原创 练习1-13
第一步:建立数组,并打印出不同长度的单词数目:#includemain(){ int c, i; int length = 0; int pitLock = 1; int charLen[10]; for (int i = 0; i < 10; i++) charLen[i] = 0; while ((c = getchar()) != EOF) { if
2017-07-11 16:45:07
440
原创 练习1-12
每行输出一个单词#include#define open 1#define close 0main(){ int c, pitLock; pitLock = close; while ((c = getchar()) != EOF) { if (c == '\t' || c == ' ') { if (pitLock == open) { c
2017-07-07 11:09:37
263
原创 练习1-9 多个空格用一个空格代替
正常程序:#include main(void) { int c; int inspace=0; while((c = getchar()) != EOF) { if(c == ' ') { if(inspace == 0) { inspace = 1;
2017-07-05 15:25:10
668
原创 1.8
#includemain(){ int c, nl; nl = 0; while ((c = getchar()) != EOF) if (c == '\n') ++nl; printf("%d\n", nl);}#includemain(){ int c, nl; nl = 0; while ((c = getchar()) != EOF)
2017-07-04 16:22:36
219
原创 p8
#includemain(){ int fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; fahr = lower; while (fahr <= upper) { celsius = 5 * (fahr - 32) / 9; printf("%d\t%d\n", fa
2017-06-30 15:14:37
345
原创 fig14_14.cpp
#include#include#include#include#include"ClientData.h"using namespace std;int enterChoice();void createTextFile(fstream&);void updateRecord(fstream&);void newRecord(fstream&);void deleteRec
2017-06-29 16:45:02
581
原创 fig14_13.cpp
#include#include#include#include#include"ClientData.h"using namespace std;void outputLine(ostream&, const ClientData &);int main(){ ifstream inCredit("credit.dat", ios::in | ios::binary);
2017-06-29 12:45:28
232
原创 fig14-09
ClientData.h#pragma once#includeclass ClientData{public: ClientData(int = 0, const std::string & = "", const std::string & = "", double = 0.0); void setAccountNumber(int); int getAccountNu
2017-06-28 14:26:11
207
原创 fig14_07.cpp
#include#include#include#include#includeusing namespace std;enum RequestType {ZERO_BALANCE = 1, CREDIT_BALANCE, DEBIT_BALANCE, END};int getRequest();bool shouldDisplay(int, double);void outp
2017-06-27 14:56:48
261
原创 fig14_06.cpp
#include#include#include#include#includeusing namespace std;void outputLine(int, const string &, double);int main(){ ifstream inClientFile("clients.txt", ios::in); if (!inClientFile) {
2017-06-27 13:57:05
234
原创 fig14_03.cpp
#include#include#include#includeusing namespace std;int main(){ ofstream outClientFile("client.txt", ios::out); if (!outClientFile) { cerr << "file could not be opened" << endl; exit(EX
2017-06-26 14:33:56
244
转载 四元数
两个向量之间的内积和外积是高等代 数和解析几何中必须要讲的内容,内积在有的课本上也被称为点积, 外积则常常被称为是叉积。在教学中,我们 发现学生很容易理解两个向量的内积。这 是因为内积定义为两个向量的对应坐标相 乘再相加,得到的结果是一个实数,比较自 然。而两个向量的外积却不再是一个实数 了,而是一个和这两个向量都垂直的向量. 这样子进行教学,学生会觉得内积和外积 差别很大,内积是数,而外积是向量
2017-06-22 17:42:47
836
原创 fig13_03.cpp
#includeusing namespace std;int main(){ const char *const word = "again"; cout << "Value of word is: " << word << endl (word) is: " (word) << endl;}
2017-06-22 15:19:36
224
原创 fig12_17.cpp
Employee.h#pragma once#includeclass Employee{public: Employee(const std::string &, const std::string &, const std::string &); virtual ~Employee() {} void setFirstName(const std::string &)
2017-06-22 11:09:17
498
原创 fig12_01.cpp
#include#include#include"CommissionEmployee.h"#include"BasePlusCommissionExployee.h"using namespace std;int main(){ CommissionEmployee commissionEmployee( "Sue", "Jones", "222-22-2222", 100
2017-06-16 14:27:23
254
原创 fig11.15
CommissionEmployee.h#pragma once#includeclass CommissionEmployee{public: CommissionEmployee(const std::string &, const std::string &, const std::string &, double = 0.0, double = 0.0); void
2017-06-15 11:02:43
233
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人