我试图获得一个字符串作为输入,cin并且它工作,但当我尝试int在字符串之后获得一个输入时,控制台将不会要求它并且程序关闭.这是我的代码:
#include <iostream>
#include <string>
using namespace std;
void main(void)
{
string a, b;
int c, d, e;
cout << "Enter two words \n";
cin >> a, b;
cout << "Enter three int";
cin >> c, d, e;
cout << c*d;
}
Run Code Online (Sandbox Code Playgroud)
这段代码不允许我输入第二个输入,但是我可以在程序关闭之前看到第二个输出.
我在aws上设置了一个看起来像这样的集群
- mycluster
--- shard0
----- node0 : P
----- node1 : S
----- node2 : S
--- shard1
----- node0: P
----- node1: S
----- node2: S
--- shard2
----- node0: P
----- node1: S
----- node2: S
Run Code Online (Sandbox Code Playgroud)
我想通过连接字符串URI连接到它.
我的连接字符串目前看起来像这样:
mongodb://host0:portX,...,host9:portZ/test-database?replicaSet=mycluster
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,当我尝试连接它时,我得到错误无法访问.
但是,我可以很好地连接到单个分片.
mongodb://host0:portX,...,host3:portZ/test-database?replicaSet=shard0
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么阻止我连接到整个群集?
如果我们有一行代码:
typedef bool (*cmp_func)(int i0, int i1);
Run Code Online (Sandbox Code Playgroud)
如何将其更改为:
typedef bool (*cmp_func)(T i0, T i1);
Run Code Online (Sandbox Code Playgroud)
哪里T - typename?
Does there exist a case where the character ( directly followed by < would be valid C++ (except for when inside a string)?
Assuming the translation unit has been pre-processed and no macros exist.
变量i在2和之间切换3并相乘a,如下例所示:
a=2;
a=a*i // a=2*2=4 i=2
a=a*i // a=4*3=12 i=3
a=a*i // a=12*2=24 i=2
a=a*i // a=24*3=72 i=3
Run Code Online (Sandbox Code Playgroud)
只要a是< 1000.
如何i按顺序给出这两个值,如示例所示?
所以我想避免输入9999可能的结果做这样的事情:
if($experience==50) {echo 'level 2'; }
if($experience==300) {echo 'level 3'; }
if($experience==700) {echo 'level 4'; }
if($experience==1000) {echo 'level 5'; }
Run Code Online (Sandbox Code Playgroud)
有办法吗?所以是的,我希望有人可以帮助我!
编辑:最高级别是99所以我还要检查
if($level == 1 && $experience >= 50) { echo 'level 2';}