迅速在两个含有大量数据的文件中寻找相同的数据
|
|
|
- 于 徐
- 7 years ago
- Views:
Transcription
1 迅速在两个含有大量数据的文件中寻找相同的数据 求解问题如下 : 在本地磁盘里面有 file1 和 file2 两个文件, 每一个文件包含 500 万条随机整数 ( 可以重复 ), 最大不超过 也就是一个 int 表示范围 要求写程序将两个文件中都含有的整数输出到一个新文件中 要求 : 1. 程序的运行时间不超过 5 秒钟 2. 没有内存泄漏 3. 代码规范, 能要考虑到出错情况 4. 代码具有高度可重用性及可扩展性, 以后将要在该作业基础上更改需求 初一看, 觉得很简单, 不就是求两个文件的并集嘛, 于是很快写出了下面的代码 #include<iostream> #include<vector> #include<cstdlib> #include<algorithm> #include<fstream> using namespace std; void merge(const vector<int> &, const vector<int>&, vector<int> &); // Author: // [email protected] // blog: // 仅用于学习交流, 转载请务必留下这些注释 int main(){ vector<int> v1, v2; vector<int> result; char buf[512]; FILE *fp; fp = fopen("file1", "r"); if(fp < 0){ cout<<"open file failed!\n"; while(fgets(buf, 512, fp)!= NULL){ v1.push_back(atoi(buf)); 1 / 9
2 sort(v1.begin(), v1.end()); fclose(fp); fp = fopen("file2", "r"); if(fp < 0){ cout<<"open file2 failed!\n"; while(fgets(buf, 512, fp)!= NULL){ v2.push_back(atoi(buf)); sort(v2.begin(), v2.end()); cout<<v1[v1.size() - 1]<<endl; cout<<v2[v2.size() - 1]<<endl; fclose(fp); merge(v1, v2, result); cout<<result.size(); ofstream output; output.open("result"); if(output.fail()){ cerr<<"crete file failed!\n"; vector<int>::const_iterator p = result.begin(); for(; p!= result.end(); p++){ output<<*p<<endl; output.close(); return 0; void merge(const vector<int>& v1, const vector<int>& v2, vector<int> &result){ vector<int>::const_iterator p1, p2; p1 = v1.begin(); p2 = v2.begin(); while((p1!= v1.end()) && p2!= v2.end()){ if(*p1 < *p2){ p1++; else if(*p1 > *p2){ p2++; else{ 2 / 9
3 result.push_back(*p1); p1++; p2++; 编译运行 : 一看, 不行, 不满足上面的 5 秒之内, 于是又想了很久, 上面不是显示 sys 调用花了很长时间嘛, 于是有写了一个程序, 用快速排序 + 二分查找法实现, 代码如下 : #include <iostream> #include <fstream> #include <vector> #include <cstdlib> #include <cstdio> #define MAXLINE 32 using namespace std; void qsort(vector<int>&, int, int); int partition(vector<int>&, int, int); bool binarysearch(const vector<int>&, int); // Author: // [email protected] // blog: // 仅用于学习交流, 转载请务必留下这些注释 int main(){ vector<int> v1, result; int temp; char buf[maxline]; FILE *fd; 3 / 9
4 fd = fopen("file1", "r"); if(fd == NULL){ cerr<<"open file1 failed!\n"; while(fgets(buf, MAXLINE, fd)!= NULL){ v1.push_back(atoi(buf)); fclose(fd); //cout<<v1.size()<<endl; qsort(v1, 0, v1.size() - 1); /*vector<int>::const_iterator p = v1.begin(); for(; p!= v1.end(); p++){ cout<<*p<<endl; sleep(1); */ fd = fopen("file2", "r"); if(fd == NULL){ cerr<<"open file2 failed!\n"; while(fgets(buf, MAXLINE, fd)!= NULL){ temp = atoi(buf); if(binarysearch(v1, temp)){ result.push_back(temp); cout<<result.size(); return 0; void qsort(vector<int> &v, int low, int hight){ if(low < hight){ int mid = partition(v, low, hight); qsort(v, low, mid - 1); qsort(v, mid + 1, hight); int partition(vector<int> &v, int min, int max){ 4 / 9
5 int temp = v[min]; while(min < max){ while(min < max && v[max] >= temp) max--; v[min] = v[max]; while(min < max && v[min] <= temp) min++; v[max] = v[min]; v[min] = temp; return min; bool binarysearch(const vector<int> &v, int key){ int low, hight, mid; low = 0; hight = v.size() - 1; while(low <= hight){ mid = (low + hight) /2; if(v[mid] == key){ return true; else if(v[mid] < key){ low = mid + 1; else{ hight = mid - 1; return false; 正乐着呢, 编译运行 : 结果发现,user 时间是 秒, 整个时间还要比以前长, 显然这种方法还是不行, 原因就是两个文件太大了,500 万条, 不是一般小, 且上面花的时间主要用在排序上面去了, 于是就想, 能不 5 / 9
6 能不用排序完成? 这时有个朋友和我说了一下位图法, 灵感一来, 自己又去改写了代码 : #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <fstream> #include <string> #include <vector> #include <algorithm> #include <iterator> #define SHIFT 5 #define MAXLINE 32 #define MASK 0x1F using namespace std; // Author: // [email protected] // blog: // 仅用于学习交流, 转载请务必留下这些注释 void setbit(int *bitmap, int i){ bitmap[i >> SHIFT] = (1 << (i & MASK)); bool getbit(int *bitmap1, int i){ return bitmap1[i >> SHIFT] & (1 << (i & MASK)); size_t getfilesize(ifstream &in, size_t &size){ in.seekg(0, ios::end); size = in.tellg(); in.seekg(0, ios::beg); return size; char * fillbuf(const char *filename){ size_t size = 0; ifstream in(filename); if(in.fail()){ cerr<< "open " << filename << " failed!" << endl; getfilesize(in, size); 6 / 9
7 char *buf = (char *)malloc(sizeof(char) * size + 1); if(buf == NULL){ cerr << "malloc buf error!" << endl; in.read(buf, size); in.close(); buf[size] = ' '; return buf; void setbitmask(const char *filename, int *bit){ char *buf, *temp; temp = buf = fillbuf(filename); char *p = new char[11]; int len = 0; while(*temp){ if(*temp == '\n'){ p[len] = ' '; len = 0; //cout<<p<<endl; setbit(bit, atoi(p)); else{ p[len++] = *temp; temp++; delete buf; void comparebit(const char *filename, int *bit, vector<int> &result){ char *buf, *temp; temp = buf = fillbuf(filename); char *p = new char[11]; int len = 0; while(*temp){ if(*temp == '\n'){ p[len] = ' '; len = 0; if(getbit(bit, atoi(p))){ result.push_back(atoi(p)); else{ p[len++] = *temp; temp++; 7 / 9
8 delete buf; int main(){ vector<int> result; unsigned int MAX = (unsigned int)(1 << 31); unsigned int size = MAX >> 5; int *bit1; bit1 = (int *)malloc(sizeof(int) * (size + 1)); if(bit1 == NULL){ cerr<<"malloc bit1 error!"<<endl; memset(bit1, 0, size + 1); setbitmask("file1", bit1); comparebit("file2", bit1, result); delete bit1; cout<<result.size(); sort(result.begin(), result.end()); vector< int >::iterator it = unique(result.begin(), result.end()); ofstream of("result"); ostream_iterator<int> output(of, "\n"); copy(result.begin(), it, output); return 0; 这是利用位图法实现的程序, 编译运行 运行时间明显比前两个少, 但是这个程序是以空间换取时间, 程序运行的时候分配了几百兆的空间 可见在程序设计中, 方法很重要 什么情况选用什么方法 但是还是觉得前面两个方法还行, 因为需要的空间比较少 ( 转载请注明 : 请不要用于商业目的 ) 8 / 9
9 Powered by TCPDF ( 迅速在两个含有大量数据的文件中寻找相同的数据 本博客文章除特别声明, 全部都是原创! 禁止个人和公司转载本文 谢谢理解 : 过往记忆 ( 本文链接 : () 9 / 9
C/C++语言 - C/C++数据
C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;
新版 明解C++入門編
511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,
2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d
2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,
C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9
201 201 21 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 1 B 1 C 5 D RPG 10 E 10 F 1 G II 1 1 201 201 C 1 # include 2 int main ( void
Guava学习之Resources
Resources 提供提供操作 classpath 路径下所有资源的方法 除非另有说明, 否则类中所有方法的参数都不能为 null 虽然有些方法的参数是 URL 类型的, 但是这些方法实现通常不是以 HTTP 完成的 ; 同时这些资源也非 classpath 路径下的 下面两个函数都是根据资源的名称得到其绝对路径, 从函数里面可以看出,Resources 类中的 getresource 函数都是基于
C 1
C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=
CC213
: (Ken-Yi Lee), E-mail: [email protected] 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,
第3章.doc
3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo
概述
OPC Version 1.8 build 0925 KOCRDK Knight OPC Client Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOC_Init...5 2.2.2 KOC_Uninit...5 2.3...5
Microsoft PowerPoint - Class5.pptx
C++ 程式初探 V 2015 暑期 ver. 1.0.1 C++ 程式語言 大綱 1. 大量檔案讀取 & 計算 2. 指標 3. 動態記憶體 & 動態陣列 4. 標準函式庫 (STL) vector, algorithm 5. 結構與類別 2 大量檔案讀取 & 計算 若目前有一個程式將讀取純文字文件 (.txt) 中的整數, 並將該文件中的整數有小到大排序後, 儲存到另外一個新的純文字件中 假設有
FY.DOC
高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主
Flume-ng与Mysql整合开发
Flume-ng 与 Mysql 整合开发 我们知道,Flume 可以和许多的系统进行整合, 包括了 Hadoop Spark Kafka Hbase 等等 ; 当然, 强悍的 Flume 也是可以和 Mysql 进行整合, 将分析好的日志存储到 Mysql( 当然, 你也可以存放到 pg oracle 等等关系型数据库 ) 不过我这里想多说一些 :Flume 是分布式收集日志的系统 ; 既然都分布式了,
通过Hive将数据写入到ElasticSearch
我在 使用 Hive 读取 ElasticSearch 中的数据 文章中介绍了如何使用 Hive 读取 ElasticSearch 中的数据, 本文将接着上文继续介绍如何使用 Hive 将数据写入到 ElasticSearch 中 在使用前同样需要加入 elasticsearch-hadoop-2.3.4.jar 依赖, 具体请参见前文介绍 我们先在 Hive 里面建个名为 iteblog 的表,
Hive:用Java代码通过JDBC连接Hiveserver
Hive: 用 Java 代码通过 JDBC 连接 Hiveserver 我们可以通过 CLI Client Web UI 等 Hive 提供的用户接口来和 Hive 通信, 但这三种方式最常用的是 CLI;Client 是 Hive 的客户端, 用户连接至 Hive Server 在启动 Client 模式的时候, 需要指出 Hive Server 所在节点, 并且在该节点启动 Hive Server
Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc
2 5 8 11 0 1. 13 2. 15 3. 18 1 1. 22 2. 25 3. 27 2 1. 35 2. 38 3. 41 4. 43 5. 48 6. 50 3 1. 56 2. 59 3. 63 4. 65 5. 69 13 22 35 56 6. 74 7. 82 8. 84 9. 87 10. 97 11. 102 12. 107 13. 111 4 114 1. 114 2.
使用MapReduce读取XML文件
使用 MapReduce 读取 XML 文件 XML( 可扩展标记语言, 英语 :extensible Markup Language, 简称 : XML) 是一种标记语言, 也是行业标准数据交换交换格式, 它很适合在系统之间进行数据存储和交换 ( 话说 Hadoop H ive 等的配置文件就是 XML 格式的 ) 本文将介绍如何使用 MapReduce 来读取 XML 文件 但是 Had oop
C++ 程序设计 OJ9 - 参考答案 MASTER 2019 年 6 月 7 日 1
C++ 程序设计 OJ9 - 参考答案 MASTER 2019 年 6 月 7 日 1 1 CARDGAME 1 CardGame 题目描述 桌上有一叠牌, 从第一张牌 ( 即位于顶面的牌 ) 开始从上往下依次编号为 1~n 当至少还剩两张牌时进行以下操作 : 把第一张牌扔掉, 然后把新的第一张放到整叠牌的最后 请模拟这个过程, 依次输出每次扔掉的牌以及最后剩下的牌的编号 输入 输入正整数 n(n
Microsoft PowerPoint - string_kruse [兼容模式]
Strings Strings in C not encapsulated Every C-string has type char *. Hence, a C-string references an address in memory, the first of a contiguous set of bytes that store the characters making up the string.
概述
OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3
1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File
51 C 51 51 C C C C C C * 2003-3-30 [email protected] C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test
新・明解C言語入門編『索引』
!... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177
三种方法实现Hadoop(MapReduce)全局排序(1)
三种方法实现 Hadoop(MapReduce) 全局排序 () 三种方法实现 Hadoop(MapReduce) 全局排序 () 我们可能会有些需求要求 MapReduce 的输出全局有序, 这里说的有序是指 Key 全局有序 但是我们知道,MapReduce 默认只是保证同一个分区内的 Key 是有序的, 但是不保证全局有序 基于此, 本文提供三种方法来对 MapReduce 的输出进行全局排序
int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;
Memory & Pointer [email protected] 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,
38 47995529 威 福 髮 藝 店 桃 園 市 蘆 竹 區 中 山 里 福 祿 一 街 48 號 地 下 一 樓 50,000 獨 資 李 依 純 105/04/06 府 經 登 字 第 1059003070 號 39 47995534 宏 品 餐 飲 桃 園 市 桃 園 區 信 光 里 民
1 08414159 惠 鴻 眼 鏡 行 桃 園 市 中 壢 區 福 德 里 中 華 路 一 段 186 號 1 樓 30,000 獨 資 宋 耀 鴻 105/04/27 府 經 登 字 第 1059003866 號 2 17891110 承 元 冷 氣 空 調 工 程 行 桃 園 市 桃 園 區 中 德 里 國 際 路 1 段 98 巷 50 號 2 樓 之 4 200,000 獨 資 詹 安 平
2 12
SHENZHEN BRILLIANT CRYSTAL TECHNOLOGIC CO.,LTD. The specification for the following models Graphic LCM serial communication control board CB001 PROPOSED BY APPROVED Design Approved TEL:+86-755-29995238
untitled
1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override
Hadoop元数据合并异常及解决方法
Hadoop 元数据合并异常及解决方法 这几天观察了一下 Standby NN 上面的日志, 发现每次 Fsimage 合并完之后,Standby NN 通知 Active NN 来下载合并好的 Fsimage 的过程中会出现以下的异常信息 : 2014-04-23 14:42:54,964 ERROR org.apache.hadoop.hdfs.server.namenode.ha. StandbyCheckpointer:
全国计算机技术与软件专业技术资格(水平)考试
全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 2008 年 上 半 年 程 序 员 下 午 试 卷 ( 考 试 时 间 14:00~16:30 共 150 分 钟 ) 试 题 一 ( 共 15 分 ) 阅 读 以 下 说 明 和 流 程 图, 填 补 流 程 图 中 的 空 缺 (1)~(9), 将 解 答 填 入 答 题 纸 的 对 应 栏 内 [ 说 明
在Spring中使用Kafka:Producer篇
在某些情况下, 我们可能会在 Spring 中将一些 WEB 上的信息发送到 Kafka 中, 这时候我们就需要在 Spring 中编写 Producer 相关的代码了 ; 不过高兴的是,Spring 本身提供了操作 Kafka 的相关类库, 我们可以直接通过 xml 文件配置然后直接在后端的代码中使用 Kafka, 非常地方便 本文将介绍如果在 Spring 中将消息发送到 Kafka 在这之前,
Microsoft Word - CPE考生使用手冊160524.docx
大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該
ebook15-C
C 1 1.1 l s ( 1 ) - i i 4. 14 - d $ l s -ldi /etc/. /etc/.. - i i 3077 drwxr-sr-x 7 bin 2048 Aug 5 20:12 /etc/./ 2 drwxr-xr-x 13 root 512 Aug 5 20:11 /etc/../ $ls -ldi /. /..... i 2 2 drwxr-xr-x 13 root
C语言的应用.PDF
AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local
2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%
2013 ( 28 ) ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 10 B 1 C 1 D 5 E 5 F 1 G II 5 H 30 1 2013 C 1 #include 2 int main(void) 3
ebook39-5
5 3 last-in-first-out, LIFO 3-1 L i n e a r L i s t 3-8 C h a i n 3 3. 8. 3 C + + 5.1 [ ] s t a c k t o p b o t t o m 5-1a 5-1a E D 5-1b 5-1b E E 5-1a 5-1b 5-1c E t o p D t o p D C C B B B t o p A b o
目录
ALTERA_CPLD... 3 11SY_03091... 3 12SY_03091...4....5 21 5 22...8 23..10 24..12 25..13..17 3 1EPM7128SLC.......17 3 2EPM7032SLC.......18 33HT46R47......19..20 41..20 42. 43..26..27 5151DEMO I/O...27 52A/D89C51...28
Microsoft Word - 01.DOC
第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的
C H A P T E R 7 Windows Vista Windows Vista Windows Vista FAT16 FAT32 NTFS NTFS New Technology File System NTFS
C H P T E R 7 Windows Vista Windows Vista Windows VistaFT16 FT32NTFS NTFSNew Technology File System NTFS 247 6 7-1 Windows VistaTransactional NTFS TxFTxF Windows Vista MicrosoftTxF CIDatomicity - Consistency
untitled
1 DBF (READDBF.C)... 1 2 (filetest.c)...2 3 (mousetes.c)...3 4 (painttes.c)...5 5 (dirtest.c)...9 6 (list.c)...9 1 dbf (readdbf.c) /* dbf */ #include int rf,k,reclen,addr,*p1; long brec,erec,i,j,recnum,*p2;
( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)
( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.
untitled
1 7 7.1 7.2 7.3 7.4 7.5 2 7.1 VFT virtual 7.1 3 1 1. 2. public protected public 3. VFT 4. this const volatile 4 2 5. ( ) ( ) 7.1 6. no-static virtual 7.2 7. inline 7.3 5 3 8. this this 9. ( ) ( ) delete
C++ 程序设计 实验 2 - 参考答案 MASTER 2017 年 5 月 21 日 1
C++ 程序设计 实验 2 - 参考答案 MASTER 2017 年 5 月 21 日 1 1 CRECT 类 1 CRect 类 设计矩形类, 包含 长度和宽度信息 基本构造函数 基础属性的访问接口 ( 读 / 写, Read/Write, Get/Set) 计算周长和面积 ( 注 : 基本构造函数, 一个无参数的默认构造函数, 以及一个初始化数据成员的构造函数如果数据成员的初始化有多种形式, 就提供多个构造函数
epub 33-8
8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE
6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit
6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128
提问袁小兵:
C++ 面 试 试 题 汇 总 柯 贤 富 管 理 软 件 需 求 分 析 篇 1. STL 类 模 板 标 准 库 中 容 器 和 算 法 这 部 分 一 般 称 为 标 准 模 板 库 2. 为 什 么 定 义 虚 的 析 构 函 数? 避 免 内 存 问 题, 当 你 可 能 通 过 基 类 指 针 删 除 派 生 类 对 象 时 必 须 保 证 基 类 析 构 函 数 为 虚 函 数 3.
江门:中国第一侨乡
开平碉楼 赤坎古镇 油菜花 梁启超故居 小鸟天堂 川岛 富康温 泉 帝都温泉 中国第一侨乡 封面... 1 一... 4 二 江门必玩景点... 6 1 碉楼游... 6 2 海岛游... 7 3 温泉游... 9 4 人文游... 11 5 生态游... 13 三 江门行程推荐... 四 江门娱乐... 五 江门美食... 六 江门购物... 七 江门住宿... 八 江门交通... 1 飞机...
INTRODUCTION TO COM.DOC
How About COM & ActiveX Control With Visual C++ 6.0 Author: Curtis CHOU [email protected] This document can be freely release and distribute without modify. ACTIVEX CONTROLS... 3 ACTIVEX... 3 MFC ACTIVEX
untitled
MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12
是 喔, 就 是 那 個 在 BBS 醫 療 版 跟 你 嗆 聲, 自 稱 有 三 十 多 年 推 拿 經 驗 的 大 叔 嗎? 一 個 看 來 頗 為 清 秀 的 女 生 問 道, 她 語 氣 中 略 感 訝 異 是 啊, 什 麼 推 拿 按 摩 有 多 好, 還 要 人 生 病 盡 量 不 要
[tw] 天 醫 傳 奇 回 憶 篇 [/tw][cn] 天 医 传 奇 回 忆 篇 [/cn] 少 年 的 時 光 是 容 易 凋 謝 的 玫 瑰, 又 像 是 不 停 等 的 河 流, 總 會 在 某 一 個 渡 口 駐 岸 時, 才 發 現, 滾 滾 河 水 夾 帶 著 輕 舟, 在 不 經 意 間, 已 經 漂 流 過 萬 重 山 A.D.1999.12.31 傍 晚 新 竹 綠 莎 庭 園
C++11概要 ライブラリ編
C++11 Egtra 2012 6 23 1 Boost. #9 1.1 C++11 1.2 http://creativecommons.org/licenses/by-sa/2.1/jp/ - 2.1 2 Misc 2.1 C++11 unique_ptr shared_ptr // #include std::unique_ptr up(new int(1));
CC213
: (Ken-Yi Lee), E-mail: [email protected] 177 [P179] (1) - [P181] [P182] (2) - for [P183] (3) - switch [P184] [P187] [P189] [P194] 178 [ ]; : : int var; : int var[3]; var 2293620 var[0] var[1] 2293620
C++ 程序设计 OJ4 - 参考答案 MASTER 2019 年 5 月 30 日 1
C++ 程序设计 OJ4 - 参考答案 MASTER 2019 年 月 30 日 1 1 STRINGSORT 1 StringSort 题目描述 编写程序, 利用 string 类完成一个字符串中字符的排序 ( 降序 ) 并输出 输入描述 输入仅一行, 是一个仅由大小写字母和数字组成的字符串 输出描述 输出排序后的字符串 样例输入 abcde 样例输出 edcba 提示 使用 std::sort
Microsoft Word - ch04三校.doc
4-1 4-1-1 (Object) (State) (Behavior) ( ) ( ) ( method) ( properties) ( functions) 4-2 4-1-2 (Message) ( ) ( ) ( ) A B A ( ) ( ) ( YourCar) ( changegear) ( lowergear) 4-1-3 (Class) (Blueprint) 4-3 changegear
Microsoft Word - 实用案例.doc
计 算 机 系 统 应 用 2009 年 第 12 期 嵌 入 式 Linux 下 温 湿 度 传 感 器 的 设 计 与 实 现 1 Design and Implementation of Temperature and Humidity Sensor Based on Embedded Linux 陈 博 刘 锦 高 ( 华 东 师 范 大 学 电 子 科 学 技 术 系 上 海 200241)
Microsoft PowerPoint - 4. 数组和字符串Arrays and Strings.ppt [兼容模式]
Arrays and Strings 存储同类型的多个元素 Store multi elements of the same type 数组 (array) 存储固定数目的同类型元素 如整型数组存储的是一组整数, 字符数组存储的是一组字符 数组的大小称为数组的尺度 (dimension). 定义格式 : type arrayname[dimension]; 如声明 4 个元素的整型数组 :intarr[4];
3.1 num = 3 ch = 'C' 2
Java 1 3.1 num = 3 ch = 'C' 2 final 3.1 final : final final double PI=3.1415926; 3 3.2 4 int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5 3.2 Java int long num=32967359818l; C:\java\app3_2.java:6:
nooog
C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1
bingdian001.com
TSM12M TSM12 STM8L152C6, STM8L152R8 MSP430F5325 [email protected]! /******************************************************************************* * : TSM12.c * : * : 2013/10/21 * : TSM12, STM8L f(sysclk)
static struct file_operations gpio_ctl_fops={ ioctl: gpio_ctl_ioctl, open : gpio_open, release: gpio_release, ; #defineled1_on() (GPBDAT &= ~0x1) #def
Kaise s 2410 Board setting [1]. Device Driver Device Driver Linux s Kernel ARM s kernel s3c2410_kernel2.4.18_r1.1_change.tar.bz2 /usr/src (1) #cd /usr/src (2) #tar xfj s3c2410_kernel2.4.18_r1.1_change.tar.bz2
C++ 程式設計
C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004
BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2
PowerBuilder 9 PowerBuilder Native Interface(PBNI) PowerBuilder 9 PowerBuilder C++ Java PowerBuilder 9 PBNI PowerBuilder Java C++ PowerBuilder NVO / PowerBuilder C/C++ PowerBuilder 9.0 PowerBuilder Native
上海浦~1
上 海 浦 发 银 行 参 与 高 等 职 业 教 育 人 才 培 养 年 度 报 告 ( ) 一 校 企 合 作 概 况 ( 一 ) 企 业 简 介 上 海 浦 东 发 展 银 行 股 份 有 限 公 司 ( 以 下 简 称 : 浦 发 银 行 ) 是 1992 年 8 月 28 日 经 中 国 人 民 银 行 批 准 设 立 1993 年 1 月 9 日 开 业 1999 年 在 上 海 证 券
Microsoft PowerPoint - plan06.ppt
程 序 设 计 语 言 原 理 Principle of Programming Languages 裘 宗 燕 北 京 大 学 数 学 学 院 2012.2~2012.6 6. 基 本 控 制 抽 象 子 程 序 抽 象 子 程 序 活 动 和 局 部 环 境 静 态 实 现 模 型 一 般 实 现 模 型 调 用 序 列 和 在 线 展 开 参 数 机 制 泛 型 子 程 序 异 常 处 理 其
<4D6963726F736F667420576F7264202D20313031A67EAF64BEC7BCFABEC7AAF7C2B2B3B95FA5FEB3A1AAA95F2D31312E31362E646F63>
教 育 部 101 年 留 學 獎 學 金 行 政 契 約 書 附 錄 九 教 育 部 101 年 留 學 獎 學 金 行 政 契 約 書 ( 可 自 行 影 印 所 需 使 用 份 數 ) 甲 方 : 教 育 部 ( 以 下 簡 稱 本 部 ) 乙 方 : 留 學 獎 學 金 甄 試 錄 取 者 ( 以 下 簡 稱 留 獎 生 ) ( 填 寫 時 務 請 詳 閱 契 約 內 容 ) 茲 經 甲 乙
得 依 法 召 集 股 東 臨 時 會 第 十 一 條 : 股 東 常 會 之 召 集 應 於 開 會 三 十 日 前, 股 東 臨 時 會 之 召 集 應 於 開 會 十 五 日 前, 將 開 會 日 期 地 點 及 召 集 事 由 通 知 各 股 東 並 公 告 之 第 十 二 條 : 本 公
旺 旺 友 聯 產 物 保 險 股 份 有 限 公 司 章 程 第 一 章 總 則 第 一 條 : 本 公 司 依 照 公 司 法 及 保 險 法 之 規 定 組 織 設 立, 定 名 為 旺 旺 友 聯 產 物 保 險 股 份 有 限 公 司 第 二 條 : 本 公 司 以 辦 理 產 物 保 險 業 務, 促 進 社 會 福 利 及 工 商 繁 榮 為 宗 旨 第 三 條 : 本 公 司 設 總
同 時, 那 些 百 萬 富 翁 們 正 乘 坐 着 私 家 噴 射 機 駛 往 歐 洲, 甘 願 花 大 把 的 鈔 票 接 受 替 代 療 法 並 且 重 獲 了 健 康 替 代 療 法 總 是 很 靈 嗎? 不, 當 然 不 是 在 這 世 界 上 没 有 盡 善 盡 美 的 事 物 但 是
美 國 頂 尖 醫 生 談 癌 症 - 太 珍 貴 了!! 我 可 以 向 你 們 保 證 以 下 的 内 容 100% 真 實, 請 您 一 定 耐 心 看 完 從 醫 15 年 來, 我 也 反 覆 告 訴 病 人 這 些 事 實, 但 是 没 有 人 願 意 去 聽, 更 没 有 人 願 意 去 相 信 或 許, 我 們 的 同 胞 們 真 的 需 要 清 醒 了 說 的 直 白 一 點, 癌
