topics

全部话题 - 话题: decrement
1 2 3 末页 (共3页)
w*********s
发帖数: 277
1
来自主题: JobHunting版 - 新手请教:C++ decrement loop (转载)
【 以下文字转载自 Programming 讨论区 】
发信人: woganmitbbs (我gan买买提), 信区: Programming
标 题: 新手请教:C++ decrement loop
发信站: BBS 未名空间站 (Mon Nov 1 15:41:40 2010, 美东)
编程新手,请不吝赐教!
for(unsigned int idx = 9; idx >= 0; idx--) {
cout << "index is " << idx << endl;
}
这么简单的都没调通,很郁闷。这个loop不能terminate,即使idx已经是负数了。
最原始的本意是作为vector的index,所以用的vector::size_type,发现不能
terminate,所以就换成unsigned int试试,仍然不terminate。
谢谢指点!
a**y
发帖数: 43
2
来自主题: EnglishChat版 - 有decrementing这样的用法吗
觉得decrement是名词,难道可以当动词来用?
s**d
发帖数: 787
3
来自主题: EnglishChat版 - 有decrementing这样的用法吗
I am not sure, but you can use decremental instead.
Thanks.
r****o
发帖数: 1950
4
经常看到increment作动词的用法,但查字典都说是名词。
请问如果increment/decrement可以作动词的话,与increase/decrease有何区别?
x*s
发帖数: 67
5
"increment" and "decrement" are commonly used in software documentation,
computer science literature and programs as verbs. Such use is also common
in conversations among system/software engineers and programmers. It's not
grammatically correct but widely accepted in computer-related fields. Just
remember not to use them as verbs in other fields or when talking to non-
techies.
f**d
发帖数: 768
6
来自主题: Neuroscience版 - eBook: From computer to brain
这是一本计算神经科学的优秀著作,全文拷贝这里(图和公式缺),有兴趣的同学可以
阅读
如需要,我可以分享PDF文件(--仅供个人学习,无商业用途)
From Computer to Brain
William W. Lytton
From Computer to Brain
Foundations of Computational Neuroscience
Springer
William W. Lytton, M.D.
Associate Professor, State University of New York, Downstato, Brooklyn, NY
Visiting Associate Professor, University of Wisconsin, Madison
Visiting Associate Professor, Polytechnic University, Brooklyn, NY
Staff Neurologist., Kings County Hospital, Brooklyn, NY
In From Computer to Brain: ... 阅读全帖
n**x
发帖数: 606
7
本人纯凑绕闹,不倾向任何一方。
系统主要特点:
- 多线程。(老魏没有给出具体多少个线程,假定100个吧。我的12 core intel xeon轻
轻松松100 thread)
- 无锁。
- 单机。
数据结构:
1. 全国1000条线 (X1, X2, X... , X1000), 每条20个区段 (S1, S2, S3... S20)。
2. 每条线的每个区段的票的总数计为:T[X1,S1], T[X1, S2]....... T[X1000, S20]
抢票程序(注意举得例子是联票)
1. 100个thread处理收到的请求
2. 每个请求包括三个参数(线路, 起始站,结束战). 比如(234次列车, 济南, 上
海)。 (注意, 234次列车是从沈阳出发,到上海的, 济南是第5个区的开始,上海最
后一个区段的结束)
3. 计算过程就是把234次列车从济南到上海的每个区段的票数做interlocked.
decrement, 如下:
- Interlocked.Decrement( T[X234,S5] )
- Interlocked.Decrement( T[X234... 阅读全帖
h******8
发帖数: 55
8
来自主题: JobHunting版 - 贡献两道google面试题
my solution:
Since you need to return the counts of clicks in the past minute at any time
, the idea of resetting the counter every minute won’t work here.
It is easy to see that this is an event-driven model. Basically we have two
kinds of events here. Once a web click happens at time t, we need to
increment the counter. At time t+1, the event expires, and we need to
decrement the counter. The value of the counter is a stair-case function,
with discontinuous being the events.
Basically we need ... 阅读全帖
K**********n
发帖数: 1197
9

跟这帮自称理科的文科生物wsn实在纠缠不清楚。给丫们上点洋大人自己的说法吧,而
且都是学术圈的,已有reference一堆,其中一份是著名的兰德公司的报告。
另外,美国和澳洲已立法限制使用脑波扫描仪,拿脑波扫描仪扫本国公民已是联邦法的
重罪。不过这个比较难的是你无法证实谁接收了你的脑信号。所以立了法跟没立一个样。
Remote Mind Control Technology

Reprinted from SECRET AND SUPPRESSED: BANNED IDEAS AND HIDDEN
HISTORY, edited by Jim Keith, $12.95, available from
1-800-680-INET.
There had been an ongoing controversy over health effects of electromagnetic
fields (EMF) for years (e.g., extremely low frequency radiation and the
Navy's Project Sea... 阅读全帖
K**********n
发帖数: 1197
10
来自主题: EE版 - 版上有人懂这个技术没?
学术界珍稀有限的原版外文资料,
Remote Mind Control Technology

Reprinted from SECRET AND SUPPRESSED: BANNED IDEAS AND HIDDEN
HISTORY, edited by Jim Keith, $12.95, available from
1-800-680-INET.
There had been an ongoing controversy over health effects of electromagnetic
fields (EMF) for years (e.g., extremely low frequency radiation and the
Navy's Project Seafarer; emissions of high power lines and video display
terminals; radar and other military and industrial sources of radio
frequencies and micr... 阅读全帖
k***t
发帖数: 276
11
写个Least Recently Used Cache的Class好像是几家公司常见题。
有没有面试可用的精简一些的Sample Code?
或哪个大拿给写一个范本。谢了。
还有,copy-on-write的string class。
我这里贡献一个smart pointer class。Code来自http://www.codeproject.com/KB/cpp/SmartPointers.aspx
class RC
{
private:
int count; // Reference count
public:
void AddRef()
{
// Increment the reference count
count++;
}
int Release()
{
// Decrement the reference count and
// return the reference count.
return --count;
... 阅读全帖
l*********y
发帖数: 142
12
来自主题: JobHunting版 - 攒人品之facebook电面面经
#include
#include
#include
#include
#include
#include
#include
using namespace std;
class Counter {
public :
Counter() {
counter = 0;
}
void increment() {
counter++;
}
void decrement() {
counter --;
}
int getValue() {
return counter;
}
private:
int counter;
};
class COWString {
public:
COWString() {
pointer = NULL;
rc = new Counter();
}... 阅读全帖
b****e
发帖数: 45
13
来自主题: JobHunting版 - 问一道F家面试题
想到一个O(n^2)的greedy算法,大概思路如下:
Traverse from the last element back to the first element. For each
element a[i]:
(1) If a[i] <= a[i + 1], then continue;
(2) If a[i] > a[i + 1], then compare the cost of decreasing the
current element a[i] with the cost of deleting the elements
a[i+1]...a[j], where (i+1)<= j < n. Choose either the decrement
or deletion operation that incurs the minimum cost.

以下是程序代码:
void MakeSortedArray(int arr[], int n) {
if (n <= 1)
return;
for (... 阅读全帖
b****e
发帖数: 45
14
来自主题: JobHunting版 - 问一道F家面试题
我的理解是这样:按照从小到大排序的话,decrement应该是基于跟后续元素的比较所
作出的操作,而不是跟前面元素比较得出的操作。因此从右往左移的话,对当前元素的
decrement操作能够保证对所有后续元素的有效性。这一有效性是实现上面的greedy算
法中每一步cost函数有效性的基础。而如果从左往右的话,对当前元素的decrement操
作无法保证其对后续元素的一致有效性,所以由此而得出的cost函数也是无效的。
如果题目变成只允许increment和deletion操作,则应该从左往右判断。
大概就是这个样子,可能解释得不太清楚 :-)
t*****t
发帖数: 285
15
Given an array S of n integers, are there elements a, b, c in S such that a
+ b + c = 0? Find all unique triplets in the array which gives the sum of
zero.
Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b
≤ c)
The solution set must not contain duplicate triplets.
For example, given array S = {-1 0 1 2 -1 -4},
A solution set is:
(-1, 0, 1)
(-1, -1, 2)
class Solution {
private:
int increment(vector& nums, int l, int r){
while(l阅读全帖
S**I
发帖数: 15689
16
来自主题: JobHunting版 - [合集] 问个facebook 面试题
☆─────────────────────────────────────☆
Bayesian1 (Jason) 于 (Tue Aug 30 00:32:06 2011, 美东) 提到:
Given an array A of positive integers. Convert it to a sorted array with
minimum cost. The only valid operation are:
1) Decrement with cost = 1
2) Delete an element completely from the array with cost = value of element
☆─────────────────────────────────────☆
chenpp (chenpp) 于 (Tue Aug 30 00:37:57 2011, 美东) 提到:
my 2 cents:
允许额外花费O(n)空间么。。。
允许的话就不停地减数组中所有元素的值,减一次计数器加1,遇到减到0的就删掉,把
当前计数器值放入新开的等大... 阅读全帖
r********g
发帖数: 1351
17
来自主题: JobHunting版 - 问一道F家面试题
数组四个元素:5,6,3,3
最佳解法是:把5减成3,cost是2次decrements,把6减成3,cost是3次decrements,这
样得到的结果是:3,3,3,3 total cost是5
另外一个解法是:把最后2个3删掉,cost是3+3=6,这个就不是最优解法。
楼上的DP是正解。。。膜拜中。。
c*******t
发帖数: 1095
18
来自主题: JobHunting版 - 问求array中3个数和最接近k的解法
O(n^2)下面这段code有反例么? 没想出来反例

for(each ele in the sorted array)
{
ele = arr[i] - k;
let front be the pointer to the front of the array;
let rear be the pointer to the rear element of the array.;
// till front is not greater than rear.
while(front <= rear)
{
if(*front *rear == ele)
{
print "Found triplet "<<*front<<","<<*rear<<","< break;
}
else
{
// sum is > ele, so ... 阅读全帖
w******t
发帖数: 16937
19
来自主题: Living版 - 想设计个logo
分特,想看专业的?
看这个。声明:因为网络安全原因,我删去了一些必须删去的内容。
http://schema.org/WebPage">Google