由买买提看人间百态

topics

全部话题 - 话题: std
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
f*****i
发帖数: 835
1
来自主题: JobHunting版 - C++ Q83: 这个const_cast什么意思?
Thanks, tested following code
const int a = 2;
std::cout << &a << std::endl;

int* b = &(const_cast(a));
*b = 3;
std::cout << &a << std::endl;
std::cout << b << std::endl;
std::cout << a << std::endl;
std::cout << *b << std::endl;
result is:
004EF808
004EF808
004EF808
2
3
super confused now.

in
and
s********y
发帖数: 40
2
沉好快。。果然我话太多了么。 哈。哈哈。。 真心问一下最后一道题。 我写了一个
这样的解:
void printAnagrams(const std::string& input)
{
std::vector indices;
std::queue choosable;
std::string ret = "";
std::cout<<"Original String: "< for(size_t i = 0; i {
if(isalpha(input[i]) && ::islower(input[i]))
{
indices.push_back(i);
choosable.push(input[i]);
ret += '1'; //place holder
}
else
ret+... 阅读全帖
s********y
发帖数: 40
3
沉好快。。果然我话太多了么。 哈。哈哈。。 真心问一下最后一道题。 我写了一个
这样的解:
void printAnagrams(const std::string& input)
{
std::vector indices;
std::queue choosable;
std::string ret = "";
std::cout<<"Original String: "< for(size_t i = 0; i {
if(isalpha(input[i]) && ::islower(input[i]))
{
indices.push_back(i);
choosable.push(input[i]);
ret += '1'; //place holder
}
else
ret+... 阅读全帖
j*****y
发帖数: 1071
4
来自主题: JobHunting版 - c++ new的一个问题
这是 c++ header file new 里面的原型
void* operator new(std::size_t) throw (std::bad_alloc);
void* operator new[](std::size_t) throw (std::bad_alloc);
void operator delete(void*) throw();
void operator delete[](void*) throw();
void* operator new(std::size_t, const std::nothrow_t&) throw();
void* operator new[](std::size_t, const std::nothrow_t&) throw();
void operator delete(void*, const std::nothrow_t&) throw();
void operator delete[](void*, const std::nothrow_t&) throw();
也就是说 new 后面跟的是一个 size 的参数
可是... 阅读全帖
m*****m
发帖数: 242
5
来自主题: Programming版 - 也问个STL的问题, 谢谢
std::vector items;
Referring to the sample code above, how do you remove all elements from the
items
collections that are greater than 50?
a. items.erase(std::remove_if(items.begin(), items.end(), std::bind2nd(std::
greater(), 50)), items.end());
b. std::remove_if(items.begin(), items.end(), std::greater(50));
c. items.erase(std::remove_if(items.begin(), items.end(), std::bindlst(std::
less_equal(), 50)), items.end());
d. items.remove_if(items.begin(), items.end(), std::bind2
c**********e
发帖数: 2007
6
来自主题: Programming版 - C++ Q13: Input
#include
#include
#include
#include
using namespace std;
int main()
{
std::string line1(3, '*'), line2(5, '*');
std::cin >> line1;
std::getline(std::cin, line2);
std::cout << "Line 1:" << line1 << std::endl;
std::cout << "Line 2:" << line2 << std::endl;
std::cout << "EOF\n";
return 1;
}
Given the program above, what happens if, when the program is run, the user
enters "Hello world!" followed by a newline?
a) It will print out:
Line 1: Hello
Line 2: world!
EOF
h****e
发帖数: 2125
7
来自主题: Programming版 - c++ singleton questions

why can't? try this:
"
#include
class X
{
public:
X* getInstance() { return &_x; }
void setMember( int i ) { _i = i; }
int getMember() const { return _i; }
const int* getMemberAddr() const { return (long long)&_i; }
private:
static X _x;
int _i;
};
X X::_x;
int main()
{
X* p;
std::cout << p->getInstance() << std::endl;
p->getInstance()->setMember( 10 );
std::cout << p->getInstance()->getMember() << std::endl;
std::cout << p->ge... 阅读全帖
h****e
发帖数: 2125
8
来自主题: Programming版 - c++ singleton questions

why can't? try this:
"
#include
class X
{
public:
X* getInstance() { return &_x; }
void setMember( int i ) { _i = i; }
int getMember() const { return _i; }
const int* getMemberAddr() const { return (long long)&_i; }
private:
X() {}
~X() {}
X( const X& );
X& operator=( const X& );
static X _x;
int _i;
};
X X::_x;
int main()
{
X* p;
std::cout << p->getInstance() << std::endl;
p->getInstance()->setMember( 10 );
... 阅读全帖
x******a
发帖数: 6336
9
来自主题: Programming版 - 请教struct inside class的问题(C++)
code和编译的错误在下面。
尝试了另外两种方式编译都没有问题:
1. 把struct Obj和double plus(..)定义在class外面
2. 在total()的定义里面,用for loop而不用std::accumulate.
请教怎么回事?谢谢!
#include
#include
#include
class Foo{
struct Obj{
double a;
explicit Obj(const double& a_): a(a_){}
};
double plus(double result, const Obj& obj){
return result+ obj.a;
}
std::vector v;
public:
void append(const double& a){ v.push_back(Obj(a));}
double total() const{
return std::accumulate(v.begin(), v.... 阅读全帖
n*****3
发帖数: 1584
10
来自主题: DataSciences版 - 问一道(大)数据 algorithm (转载)
你说的对, 这不是大数据。
因为在modeling training stage, 用 R 跑prototype system,
R itself 不 方便 并行。 下一阶段 会上 spark/hadoop。
继续 抛砖引玉一下。 下面的 CPP file 跑得还行。 用 sourceRCPP call
就可。 看看有什么可以改进的,
再次 谢谢大家 all
#include
using namespace Rcpp;
using namespace std;
// Below is a the balancing C++ function to R. You can
// source this function into an R session using the Rcpp::sourceCpp
// function (or via the Source button on the editor toolbar)
// For more on using Rcpp click the Help button on the editor toolbar
// [... 阅读全帖
c********2
发帖数: 56
11
来自主题: JobHunting版 - 贴个FLEXTRADE的在线C++测试的题
面的是Associate C++ Developer,下面是面试题,光顾着记题了,最后只有56%的通过
率,要到
80%才能ONSITE,算是帮大家做点贡献吧,他家在招人,赶快去投简历
1) #include
using namespace std;
struct A{
A(int value) : m_value(value){}
int m_value;
};
struct B:A {
B(int value):A(value){}
};
int main(){
try {
try{
throw B(5);
}
catch(A a){
a.m_value *=2;
throw;
}
catch(B b){
b.m_value -=2;
throw b;
}
}
catch(A a){
... 阅读全帖
a*****y
发帖数: 22
12
来自主题: JobHunting版 - 这个Google题有什么好的解法吗?
我有一个想法:
先建立map存储价格:(设商品用id表示)
struct ItemPrice {
std::vector items;
int price;
};
std::map > item_prices_;
表示将某个商品映射到所有包含该商品的组合或单件商品的价格
所求:
std::map< std::set, int > min_price_;
int FindMinPrice(const std::set& items, const std::set& used_items
) {
std::set target;
// target = items - used_items
if (target.empty()) {
return 0;
}
if (min_prices_.count(itesms) > 0) {
return ...;
}
int min = 0x7FFFFFF;
// get the first... 阅读全帖
l****s
发帖数: 75
13
来自主题: JobHunting版 - A question about C++. Thanks.
nothing happens.
a and b are not initialized.
try this:
#include
class foo
{
private:
int a;
int *b;
public:
void print()
{
std::cout << a << std::endl;
std::cout << &a << std::endl;
std::cout << b << std::endl;
//std::cout << *b << std::endl;
}
};
void doSth()
{
foo f;
f.print();
}
void main()
{
doSth();
std::cin.get();
}

发帖数: 1
14
来自主题: JobHunting版 - 刷题弱人来问个two sum的题目
这个题目我做的只能pass一个case,不知道后面的case错在哪里了。后面附上我的代码
http://www.testdome.com/for-developers/solve-question/10283?visibility=1
http://www.testdome.com/for-developers/solve-question/10283?visibility=1
#include
#include
#include
#include
#include
class TwoSum
{
public:
static std::pair findTwoSum(const std::vector& list, int
sum)
{

std::unordered_map hashed;
for(unsigned int i = 0; i < list.si... 阅读全帖
m****g
发帖数: 984
15
来自主题: NextGeneration版 - 统计贴: 问美国公司的产假问题
楼上这些都是产假还是STD啊?如果是公司的产假还另外有STD么?
我以前的公司有三周parental leave, full pay, 男女都有。
妈妈的话还有STD,刨的8周,顺产6周,前几周full pay,后面2/3,由进公司多久决定。
注意这个8或6周是从生孩子那天开始算的,产前我们州可以在due date之前休upto4周
,我没休那么久,只提前了2周开始休,结果宝宝很淡定,比预产期晚了9天才出生,所
以我生前几乎快一个月在家闲着,呵呵。生了以后休了8周的STD加3周的parental,另外
还可以用自己的带薪假,再来还有unpaid leave.不过我还没用完带新假就回去上班了。
新公司没有parental leave了:(
STD好像前几天不pay,后面full pay,具体还没弄清楚,等需要的时候再研究吧。
另:我当时那个STD到底可以付多久自己看document很糊涂,本来以为产前休多了产后
就少了,其实不是的。这点我后来找了公司里刚生了孩子的同事问清楚的,又跟STD的
打了电话确认,而且我还问了如果我产前休了超过4周但是因为宝宝生的比预产期晚,
那么中间的gap怎么... 阅读全帖
p*u
发帖数: 2454
16
来自主题: Programming版 - how do I reseat a reference?
I know a reference in C++ cannot be reseated; am just trying to test
this concept. But it seems to me that as long as u wish to implement an
assignment operator u will not get a "reference reseating" compiler
error, it will just copy value of second object to first object. How can
I have a true compiler error?
Sample code:
"
#include
#include
int main()
{
std::vector v1( 10, 1 );
std::vector v2( 20, 2 );
std::vector& ref = v1;
for( int i = 0; i < re... 阅读全帖
A**u
发帖数: 2458
17
来自主题: Programming版 - 请教c++ interface class问题
小弟在读effective c++, 第31节
讲到interface class, 里面提到 factory function, 有些不明白, 请大家指点
下面是代码.
interface class
class Person{
public:
static std::tr1::shared_ptr create(const std::string& name);
virtual ~Person();
virtual std::string name() const = 0;
}
这里的create 就是书里说的factory 函数
class RealPerson: public Person{
public:
RealPerson(const std::string& name):thename(name){}
virtual ~RealPerson();
std::string name() const;
private:
std::string the name;
}
奇怪的是 create 实现为
std::... 阅读全帖
t****t
发帖数: 6806
18
来自主题: Programming版 - please help debug this code
OK, solved. let me explain this, this is complex.
you called copy(....begin(), ....end(), ostream_iterator<...>(...)), so
ostream_iterator will do the << for you. naturally, ostream_iterator is
within namespace std, so operator<< is called in namespace std.
Now for overload resolution. there are a lot of operator<< within namespace
std; so these are considered. your parameters to operator<< are std::basic_
ostream<...> and std::pair<...>, they are both in namespace std. Therefore
no other namesp... 阅读全帖
y**b
发帖数: 10166
19
来自主题: Programming版 - C++能不能加入一些Matlab的能力呢?
今天把一个三维CFD超声速模拟的Matlab code转成C++代码同其他模拟进行耦合,
发现C++在处理多维数组方面实在是繁琐,比如处理一个动态五维数组,光分配
就得这么搞:
std::valarray< std::valarray< std::valarray AL> > > > > arrayRoeFlux;
arrayRoeFlux.resize(nx);
for (std::size_t i = 0; i < arrayRoeFlux.size(); ++i) {
arrayRoeFlux[i].resize(ny);
for (std::size_t j = 0; j < arrayRoeFlux[i].size(); ++j) {
arrayRoeFlux[i][j].resize(nz);
for (std::size_t k = 0; k < arrayRoeFlux[i][j].size(); ++k) {
... 阅读全帖
x******a
发帖数: 6336
20
来自主题: Programming版 - 请教C++11
moneybull: yes I understand now. thank you.
pptwo: the following does not work. any suggestions are appreciated.
std::vector vec;
vec.resize(10);
std::generate_n(vec, 10, getNormal);
error C4996: 'std::_Generate_n': Function call with parameters that may be
unsafe - this call relies on the caller to check that the passed values are
correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See
documentation on how to use Visual C++ 'Checked Iterators'
1> c:\program files (... 阅读全帖
g**********y
发帖数: 423
21
千老干的活是这样的:
struct TIME
{
int seconds;
int minutes;
int hours;
};
void computeTimeDifference(struct TIME t1, struct TIME t2, struct TIME *
difference){
if(t2.seconds > t1.seconds)
{
--t1.minutes;
t1.seconds += 60;
}
difference->seconds = t1.seconds - t2.seconds;
if(t2.minutes > t1.minutes)
{
--t1.hours;
t1.minutes += 60;
}
difference->minutes = t1.minutes-t2.minutes;
difference->hours = t1.hours-t2.hours;
}
static size_t Wr... 阅读全帖
l*h
发帖数: 4124
22
来自主题: USANews版 - 恭喜加州,性病创历史新高
恭喜加州,贺喜加州,性病创历史新高,又出现大批因为先天梅毒而死产的。
https://www.cbsnews.com/news/std-cases-reach-all-time-high-in-california-
report-finds/
STD cases reach all time high in California, report finds
Associated Press, LOS ANGELES — The number of cases of sexually transmitted
diseases in California reached a record high last year and officials are
particularly concerned by a spike in stillbirths due to congenital syphilis,
state health authorities said Monday.
More than 300,000 cases of chlamydia, gonorrhea and syp... 阅读全帖
s*********t
发帖数: 1663
23
来自主题: JobHunting版 - 这个题咋做?
std::vector > kSubset( std::vector& S, int start, int
k )
{
std::vector > subs;
std::vector a;
if( k == 0 || (int)S.size() - start < k){
return subs;
}
if( S.size()-start == 1 ){
a.push_back(S[start]);
subs.push_back(a);
return subs;
}
std::vector > s1 = kSubset(S, start+1, k-1);
if(s1.size()==0){
a.push_back(S[start]);
subs.push_back(a);
}
else{
E*****7
发帖数: 128
24
来自主题: JobHunting版 - a very difficult interview question
Try this one in C++.
(1) Compute N to the power of M;
(2) Insert each of the generated result to std::map as the key of the key-value pair. std::map sorts the key exactly as required by the interview question when each key-value pair is inserted into it. In my code, the "value" is just a placeholder.
#include
#include
std::map SeriesNumber;
static unsigned value = 1;
void NtoM(unsigned n, unsigned m)
{
unsigned result = n;
for (unsigne... 阅读全帖
k********k
发帖数: 5617
25
http://www.mitbbs.com/article_t/Sex/32803551.html
发信人: LAFoxy (不甘寂寞), 信区: Sex
标 题: 各位一定要自保 我惊吓未定呢
发信站: BBS 未名空间站 (Tue Nov 11 01:08:48 2014, 美东)
在交友网站认识了一个人 在政府单位工作的 有名有姓有地址有电话 原本约了要见
面吃饭聊天的 同时我坚持对方去做STD TEST 他不肯... 我给他看我STD Clearance
Report 他竟然大怒。。。
长话短说 最后他被我逼急了 承认他有爱滋 所以见面之事立马取消 但已经把我吓
得说不出话来
他的心态是我要讲的事  根据他说 他有AIDS, Herpes, 与HPV 他在洛杉矶地区已
经睡了不少女人 算都算不清了 据他的描述 他以传播爱滋病毒为AGENDA 被我识破
后 他说我太Smart 竟让我给跑了 他要马上找下一个VICTIM
他提到他来者不拒 亚女白女拉丁女全部睡 他说他这一辈子算是完了 但他之前与未
来的所有女伴全部会因他而感染爱滋 而他乐此不疲 从外表或照片上完全看不出来此
人有这... 阅读全帖
b*********n
发帖数: 1258
26
想写一个functor来比较2个pair的大小,但是compile有错误, Code Below
===========================================================
error C2664: 'void __cdecl std::sort(struct std::pair *,stru
ct std::pair *,bool (__thiscall *)(struct std::pair le>,struct std::pair))'
ruct std::pair)' to 'bool (__thiscall *)(struct std::pair t,double>,struct std::pair)'
None of the functions with this name in scope match the target t
ype
Error executing cl
a*******t
发帖数: 1356
27
http://tomatousb.org/doc:build-types
Linksys E1000 v1 R2 Yes No NoUSB-Std (4MB flash) only
Linksys E2000 R2 Yes No E2000 (special E2000 Std build
required)
Linksys E3000 R2 Yes No E3000 (special E3000 Ext or VPN
build required)
Linksys E4200 R2 Yes No E4200 (special E4200 Ext or VPN
build required). No 5GHz support
Linksys WRT160N v1 R1 Yes Yes NoUSB-Std (4MB flash) only
Linksys WRT160N v3 R2 Yes ... 阅读全帖
a*******t
发帖数: 1356
28
http://tomatousb.org/doc:build-types
Linksys E1000 v1 R2 Yes No NoUSB-Std (4MB flash) only
Linksys E2000 R2 Yes No E2000 (special E2000 Std build
required)
Linksys E3000 R2 Yes No E3000 (special E3000 Ext or VPN
build required)
Linksys E4200 R2 Yes No E4200 (special E4200 Ext or VPN
build required). No 5GHz support
Linksys WRT160N v1 R1 Yes Yes NoUSB-Std (4MB flash) only
Linksys WRT160N v3 R2 Yes ... 阅读全帖
b***y
发帖数: 2799
29
☆─────────────────────────────────────☆
babyfacenan (黑土) 于 (Thu Feb 21 21:03:35 2008) 提到:
想写一个functor来比较2个pair的大小,但是compile有错误, Code Below
===========================================================
error C2664: 'void __cdecl std::sort(struct std::pair *,stru
ct std::pair *,bool (__thiscall *)(struct std::pair le>,struct std::pair))'
ruct std::pair)' to 'bool (__thiscall *)(struct std::pair t,double>,struct std::pair)'
z****e
发帖数: 2024
30
来自主题: Programming版 - 再问C++初始化问题。
为了验证我的一些想法,我写了如下代码,
标号2,4的运行区别不是很理解。
class X{
public:
int i;
};
X* px=new X;
X gox;
int main(){
X* lpx=new X;
std::cout<i< std::cout<i< X ox;
std::cout< std::cout< }
结果:
0
0
0
-1077381160
主要是2,和4,为什么2和4有区别呢?
stack和heap上,初始化还不一样?
stack和静态区不一样是可以理解的。
另外
X* lpx=new X;

X* lpx=new X();
貌似没有区别,实际有没有区别呢?
因为heap上要zero out,所以heap的效率要轻微的低于stack???
p*u
发帖数: 2454
31
来自主题: Programming版 - c++ 设计问题求助

anywhere by
setter/
you are right, but we can always solve this with another level of
indirection:
"
#define GETTER( a ) Intruder::get( *this, a )
#define SETTER( a, i ) Intruder::set( *this, a, i )
class A
{
private:
friend struct Intruder;
int _i;
};
struct Intruder
{
template
static int get( const T& ref, const A& a );
template
static void set( const T& ref, A& a, int i );
};
template
int Intruder::get( const T& ref, const A& a )... 阅读全帖
t****t
发帖数: 6806
32
来自主题: Programming版 - 为什么大家都说c++水很深?
楼上的兄弟拿一些名词出来吓唬人你可以说他不对, 但是你要说他说的几个事情"有屁
用处", 那我只能说你无知者无畏了.
我前面说了, 最简单的C++ hello world里就依赖ADL, 只是初学者没注意到而已. 说实
话不是什么高深的概念.
std::cout<<"Hello world\n";
事实上等于
operator<<(std::cout, "Hello world\n");
但是operator<<是在std::里面的, 为什么不写std::operator<<(std::cout, "Hello
world\n");? 因为参数std::cout在std::里, 所以编译器找不到operator<<(..., ...)
的时候就会去找std::operator<<. 说穿了了是很简单的一件事情, 但是没有它还不行;
有了它, 又有名污染的问题.
另外ABI的问题, 写多的人都知道是很头痛的一件事情.
提ADL和ABI这些事情, 我想devilphoenix不是想说C++很高深, 而是说C++遇到的麻烦和
陷阱远远不止什么内存分配这类的小事情. 你非要说人显摆当然我也没办... 阅读全帖
t****t
发帖数: 6806
33
来自主题: Programming版 - 为什么大家都说c++水很深?
楼上的兄弟拿一些名词出来吓唬人你可以说他不对, 但是你要说他说的几个事情"有屁
用处", 那我只能说你无知者无畏了.
我前面说了, 最简单的C++ hello world里就依赖ADL, 只是初学者没注意到而已. 说实
话不是什么高深的概念.
std::cout<<"Hello world\n";
事实上等于
operator<<(std::cout, "Hello world\n");
但是operator<<是在std::里面的, 为什么不写std::operator<<(std::cout, "Hello
world\n");? 因为参数std::cout在std::里, 所以编译器找不到operator<<(..., ...)
的时候就会去找std::operator<<. 说穿了了是很简单的一件事情, 但是没有它还不行;
有了它, 又有名污染的问题.
另外ABI的问题, 写多的人都知道是很头痛的一件事情.
提ADL和ABI这些事情, 我想devilphoenix不是想说C++很高深, 而是说C++遇到的麻烦和
陷阱远远不止什么内存分配这类的小事情. 你非要说人显摆当然我也没办... 阅读全帖
y**b
发帖数: 10166
34
来自主题: Programming版 - 请问释放容器内存的方法
linux下面我直接用ps或top命令查看的,可以清楚看到各个进程的内存消耗。
swap这个方法我用google搜索到的,似乎是通用的一个trick; effective stl里面也有
提到。
下面是源码,只有swap之后进程的内存消耗才降到近乎0(getchar的时候察看)。
#include
#include
#include
int main () {
std::vector vec;
vec.resize(10000000,-1);
std::cout << "resize finished." << std::endl;
getchar();
vec.clear();
std::cout << "clear finished." << std::endl;
getchar();
std::vector().swap(vec);
std::cout << "swap finished." << std::endl;
getchar();
ret... 阅读全帖
D***n
发帖数: 6804
35
你可以看看这个打出来什么:
const char i='x';
const char *cp=&i;
char *p;
p=const_cast(cp);
*p='y';
std::cout<<*p< std::cout<<*cp< std::cout< const char *t = &i;
std::cout<<*t< 我这里的结果是 y y x y
s**y
发帖数: 151
36
来自主题: Programming版 - 一个关于unordered_map/hashmap的问题
std::map和std::unordered_map都是container class容器类,里面保存了你加进去的
一对对的pair
std::map是用一个比较function来通过Key排序/查找pair
std::unordered_map是用一个hash function来通过Key查找pair
所以std::map或std::unordered_map需要占据多大内存,取决于你有多少数据pair ,T>加进这个容器,这个内存大小和比较function或hash function本身无关。
hash function需要把你的每一个可能的Key转变成对应的T value,并且(1)转化快速
少用额外内存;(2)所有可能的T values尽量紧凑;(3)不同T values尽可能少出现
碰撞。
以你的6个大写字面为例子,假定每个字母是在26个字母里随机抽取。
6个大写字母字符串是Key,有26^6=308,915,776种可能性。而T是int,按你的要求,
一个(0~2^30)的int有2^30=1,073,741,824... 阅读全帖
c***s
发帖数: 15
37
来自主题: Programming版 - 请教一个C++的设计问题
//样本代码如下,把具体decoder方法在不同type上实现就行
#include
enum decoder_type
{
type_A = 0,
type_B = 1,
type_C = 2,
no_decoder_available = 3
};
template
class decoder_algorithm
{
};
template<>
struct decoder_algorithm
{
static bool is_compatible () { return false; }
static void decode() { std::cout << "decoder A" << std::endl; }
};
template<>
struct decoder_algorithm
{
static bool is_compatible () { return false; }
static void decode() { std::cout << "decoder B" ... 阅读全帖
s******d
发帖数: 278
38
读了您的笔记。
// 思考:如果=之前A已经和某线程关联了怎么办?
在C++ Concurrency in Practice Chapter 2.3 Transferring ownership of a thread
, 好像可以通过std::move操作
void some_function();
void some_other_function();
std::thread t1(some_function);
std::thread t2=std::move(t1);
t1=std::thread(some_other_function);
std::thread t3;
t3=std::move(t2);
t1=std::move(t3);
l********k
发帖数: 14844
39
来自主题: Biology版 - 问一个SD值大于Ave的问题
如果被统计的数值可正可负,mean和std不需要有什么大小关系。如果被统计的数据都
是非负的,std仍然可能大于mean,这个取决于具体的分布。比如指数分布,mean =
std,[0 0 1 1],也是mean = std。而比如说[0 0 1], mean = 0.333, std = 0.47,
std > mean.
简言之,分布的不对称性越大,std越是一个不好的参数。如果要画图,通常不能画
mean +/- std bar graph,而是要画成boxplot:
R*******c
发帖数: 249
40
搞了三四天了,还是没成功,实在是崩溃了。。。只能上来请大牛们帮忙看看问题出在哪?
从网上下载了一个R的package(一个zip文件),这个包是在mac上build的,在mac里运行没有
问题,我现在想在windows下用这个包,直接通过R里面的install package from local
zip file会有错误如下:
Error in gzfile(file, "r") : cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip
file
2: In gzfile(file, "r") :
cannot open compressed file 'curves2_1.0.1.tar.gz/DESCRIPTION',
probable reason 'No such file or directory'
所以决定先将zip文件解压缩成文件夹,然后在windows下把这个包buil... 阅读全帖
t**********y
发帖数: 374
41
I did some test runs using built-in dataset and got different outputs:
1. ===
> test=lmer(Reaction~Days+(Days|Subject),sleepstudy)
> summary(test)
Linear mixed model fit by REML ['lmerMod']
Formula: Reaction ~ Days + (Days | Subject)
Data: sleepstudy
REML criterion at convergence: 1743.6
Scaled residuals:
Min 1Q Median 3Q Max
-3.9536 -0.4634 0.0231 0.4634 5.1793
Random effects:
Groups Name Variance Std.Dev. Corr
Subject (Intercept) 612.09 24.740
... 阅读全帖
w*******y
发帖数: 60932
42
Hey guys,
Been a while since I posted a deal, but here's a pretty good one IMO:
In honor of Classic Firearms new domain, they are having a special that
includes the following (their prices, not mine)
1 - Romanian Wasr 10 Hi Cap AK Rifle W/ built in Scope Rail....Std Price...$
499.99
1 - 40" Bulldog Brand Tactical Carry Case W/4 Mag Pockets , Etc..Std Price..
$34.99
4 - Tapco Brand U.S. Made 30 Round AK Mags...Std Price $9.99 ea..=.. Total..
$39.96
1 - Romanian Saw Tooth Back Wire Cutter Bayonet ... 阅读全帖
g********d
发帖数: 4174
43
来自主题: QueerNews版 - HPV From Oral Sex?
http://www.huffingtonpost.com/leigh-vinocur-md/oral-sex-cancer_
HPV From Oral Sex? Young People Often Underestimate The Risk
Ironically, April is both Sexually Transmitted Disease (STD) Awareness month
as well as Oral, Head and Neck Cancer Awareness month. Many people don't
even realize how these two diseases are linked and how they both pose a
serious health risk, especially for our adolescent boys.
As far as STDs, according to the United States Centers for Disease Control
and Prevention (CDC),... 阅读全帖
g*******t
发帖数: 1039
44
来自主题: Automobile版 - 看到一辆破车,大家点评下
free report here :)
Your AutoCheck Vehicle History Report
1996 Toyota Tercel DX / STD
Report Run Date: 2011-09-07 17:04:38.333 EDT
Report Summary
Class: Small Car - Budget
Engine: 1.5L I4 EFI
Country of Assembly: Japan
Vehicle Age: 15 year(s)
Calculated Owners: 4
VIN: JT2AC52L6T0143841
Year: 1996
Make: Toyota
Model: Tercel DX / STD
Style/Body: Sedan 2D
This vehicle's AutoCheck Score


The AutoCheck Score is a summary o... 阅读全帖
P*******b
发帖数: 1001
45
来自主题: JobHunting版 - one C++ question
f2()为啥比f1()多调用一次copy ctor
#include
struct C
{
C() { std::cout << "Ctor" << std::endl;}
C(const C&) { std::cout << "A copy was made.\n"; }
};
C f1(C c)
{
C first;
return first;
}
C f2(C c)
{
C first;
return c;
}
int main()
{
C first;
std::cout << "-----------" << std::endl;
C second = f1(first);
std::cout << "-----------" << std::endl;
f2(second);
}
c**********e
发帖数: 2007
46
来自主题: JobHunting版 - C++ Q22: ostream
#include
using namespace std;
class Base {
protected:
virtual void output(std::ostream& os) { os << "Base\n"; }
};
class Derived : private Base {
friend std::ostream& operator<<(std::ostream&, Derived&);
};
std::ostream& operator<<(std::ostream& os, Derived& d) {
d.output(os);
}
int main() {
Base b; Derived d;
std::cout << b << d;
}
For which one of the following reasons is the code above INVALID?
a) Base::output is defined for Base, but operator<< is defined for Derived.
b)
k***s
发帖数: 277
47
受到wiki上的启发, http://en.wikipedia.org/wiki/Integer_partition
wiki上是用smallest addedn is k, 我改成with m's largest addend k
// k is the maximum number of integer partition;
// m is the num of k of integer partition.
void ip_helper(int n, int k, int m, std::deque sequence) {
if (n < k*m)
return;
if (k < 1)
return;
int i, j, r = n-k*m;
for (i=0; i sequence.push_back(k);
if (r == 0) {
for (i=0; i<(int)sequence.size(); ++i)
std::c... 阅读全帖
g*****1
发帖数: 998
48
来自主题: JobHunting版 - 请教c++的string vector问题,谢谢!
g++里warning:deprecated conversion from string constant to 'char*'
刚试了"char*" to "const char*" in vc 还是不行。。
vc里的compile error很多,以下是第一个:
g:\program files\microsoft visual studio 10.0\vc\include\algorithm(4296):
error C2784: 'bool std::operator <(const std::move_iterator<_RanIt> &,const
std::move_iterator<_RanIt2> &)' : could not deduce template argument for '
const std::move_iterator<_RanIt> &' from 'std::basic_string<_Elem,_Traits,_
Ax>'
1> with
1> [
1> _Elem=char,
... 阅读全帖
t****t
发帖数: 387
49
这段程序我可以运行没问题
如果再pop一次就crash
template struct node{
node *next;
T data;
node(node* n, T d):next(n),data(d){};
};
template class stack{
public:
node *head;
int ind;
stack(){}
~stack(){}
void push(T d);
T pop();
bool isEmpty();
};
template T stack::pop(){
T d=head->data;
node *s=head;
head=head->next;
delete s;
ind--;
return d;
}
template void stack::push(T d){
if(i... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)