小编dja*_*min的帖子

GitHub for Windows安装

在安装GitHub for Windows时,如何解决此错误:

尝试下载" http://github-windows.s3.amazonaws.com/GitHub.application "时出错.

日志文件:

    The following properties have been set:
Property: [AdminUser] = true {boolean}
Property: [InstallMode] = HomeSite {string}
Property: [ProcessorArchitecture] = AMD64 {string}
Property: [VersionNT] = 6.2.0 {version}
Running checks for package 'Windows Installer 3.1', phase BuildList
The following properties have been set for package 'Windows Installer 3.1':
Running checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe'
Result of running operator 'VersionGreaterThanOrEqualTo' on property 'VersionMsi' and value '3.1': true
Result of checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe' is 'Bypass'
'Windows Installer …
Run Code Online (Sandbox Code Playgroud)

github

27
推荐指数
3
解决办法
3万
查看次数

将包含数字的字符串解析为整数数组

String是一个由数字组成的输入,我想在C++中将它转换成整数数组.

#include <string>
#include <iostream>
#include <sstream>

using std::string;
using std::stringstream;
using std::cout;
using std::endl;

int main(int argc,char** argv) {

    string num="-24 2 90 24 50 76";

    stringstream stream(num);

    while(stream){
        int n;
        stream>>n;
        cout<<n<<endl;
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出(GCC):

-24 2 90 24 50 76 76

为什么我会获得额外的价值,将它们转换为整数数组的效率是多少?

更新:

如果字符串流包含除空格之外的分隔符,如何解析此怎么办?例如: string num="-24,2,90,24,50,76";

c++ arrays string parsing

16
推荐指数
2
解决办法
4万
查看次数

在线编译器检查执行时间

我想知道任何可用的代码编译器(特别是C++),它给出了提交代码的总执行时间.

据我所知,Ideone是良好的在线编译器提供此功能.如果存在检查代码的执行时间(总运行时间)的服务,那将是非常好的.

c++ compiler-construction editor

6
推荐指数
1
解决办法
6504
查看次数

如何在C++中使用qsort for string

我想使用qsort函数使用C++对字符串中的字符进行排序.

#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int compare_str(void const *a,void const *b){
    char const *aa=(char const *)a;
    char const *bb=(char const *)b;

    if(*aa==*bb) return 0;
    else if(*aa>*bb) return 1;
    else return -1;
}
int main(){

    string str="cake";
    int len=str.length();

    qsort(str,len,sizeof(str[0]),compare_str);
    cout<<str;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但它抛出:

20 42 [Error] cannot convert 'std::string {aka std::basic_string<char>}' to 'void*' for argument '1' to 'void qsort(void*, size_t, size_t, int (*)(const void*, const void*))' 
Run Code Online (Sandbox Code Playgroud)

如果有人能提供一种有效的方法来做到这一点会很棒.

c++ qsort

5
推荐指数
1
解决办法
3398
查看次数

在antlr4中构建AST

我想知道我们是否可以使用Antlr版本4构建AST.我找不到使用antlr4构建它的任何参考.一个SO答案说,使用只生成解析树的antlr4很容易,但我的问题是效率如何呢?

它迫使我们抓取整个解析树而不是抽象语法树,这不是遍历整个树并使用访问者执行任务的有效方式.

antlr abstract-syntax-tree antlr4

4
推荐指数
1
解决办法
3536
查看次数

仅检查空值的 Javascript 最佳实践

我想检查 JavaScript 中的空值。

例如, test() 是可以返回 null 的函数。所以如果我想有效地测试空检查,我的方法应该是什么。

var a = test();
Run Code Online (Sandbox Code Playgroud)

其次是

if (a) {}
Run Code Online (Sandbox Code Playgroud)

或者

if (a !== null) {}
Run Code Online (Sandbox Code Playgroud)

? 因为if (a)将检查 null、undefined、false、0、NaN,当我们知道我们只能得到 null 值时,这可能不是最好的方法。

javascript null

3
推荐指数
2
解决办法
5832
查看次数