Programming Perl----------Column1

Problem 3.

This problem let us write all the solutions, and run, then based on the results we can get the most effective solution.

Now I don't want to compare these solutions including last file has given.

C++ bitset solution:

#include <iostream>
#include <bitset>

#define MAX_LENGTH 10000000

int main (int argc, char *argv[]) {
std::bitset<MAX_LENGTH> array;

int32_t i;
for (i = 0; i < MAX_LENGTH; i++) {
array[i] = 0;
}

i = 0;
while (std::cin >> i) {
array[i] = 1;
}

for (i = 0; i < MAX_LENGTH; i++ ) {
if (array[i]) {
std::cout << i << " is set" << std::endl;
}
}

return 0;
}


C using the last file functions:

#include <stdlib.h>
#include <stdio.h>

#define MAX_LENGTH 10000000
#define INT_LENGTH 32
#define SHIFT 5

int32_t integerArray[1 + MAX_LENGTH >> SHIFT];

void set(int32_t i){
integerArray[i >> SHIFT] |= (1 << (i & MASK));
}

void clear(int32_t i) {
integerArray[i >> SHIFT] &= ~(1 << (i & MASK));
}

int test(int32_t i) {
return integerArray[i >> SHIFT] & (1 << (i & MASK));
}

int main (void) {
int32_t i;
for (i = 0; i < 10000000; i++) {
clear(i);
}

while (scanf("%d", &i) != EOF) {
set(i);
if (test(i)) {
printf ("%d is set\n", i);
}
}

return 0;
}


动态规划(dynamic programming)原理

2016-04-30 17:21:02

五大常用算法 ----DP 动态规划（Dynamic Programming）

2016-07-24 22:35:21

Programming Tool PLC802 V3.1

2015年04月11日 33.58MB 下载

在看完《Programming in Lua》之后

2014-08-17 21:34:52

Programming in Lua 4th Edition带书签

2017年09月19日 1.16MB 下载

Efficient R Programming

2016年06月20日 2.64MB 下载

Programming Windows with MFC中文版 pdf 下载地址

2011年06月02日 320B 下载

The Elements of Programming Style 读书总结

2016-05-06 22:23:25

Extreme Programming介绍

2008-01-17 11:13:00

科学的编程-the science of programming

2014-10-19 19:35:30