我正在做的事情:
我试图将一个矢量分成两个独立的数组.当前int向量包含文本文件中每行的元素.文本文件是随机整数列表.
我打算怎么做:
我目前的想法是创建两个常规int数组,然后迭代整个向量并将n/2个元素复制到每个数组.
我想知道的是:
完成任务的最优雅方式是什么?我有一种感觉,我可以做到这一点,而无需多次迭代矢量.
码:
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
using namespace std;
vector<int> ifstream_lines(ifstream& fs)
{
vector<int> out;
int temp;
while(fs >> temp)
{
out.push_back(temp);
}
return out;
}
vector<int> MergeSort(vector<int>& lines)
{
int split = lines.size() / 2;
int arrayA[split];
int arrayB[split];
}
int main(void)
{
ifstream fs("textfile.txt");
vector<int> lines;
lines = ifstream_lines(fs);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
谢谢 :)
在我的VPS上安装GitLab之前,我正在使用Apache2.我只想让GitLab成为我网站的子域名(git.example.com),并让我的主站点(www.example.com)查看/var/www/html/index.html
这是我现在的nginx.conf文件:
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
upstream gitlab {
server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket; }
server {
listen 80;
server_name www.example.com;
root /home/gitlab/gitlab/public;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location / {
# serve static files from defined root folder;. …Run Code Online (Sandbox Code Playgroud) GitLab应在创建帐户时自动使用其密码向新用户发送电子邮件.
我检查了mail.log文件,但没有看到发送或尝试发送的记录.
我可以通过postfix命令行发送邮件没有问题.
在gitlab ui中,我没有失败或任何事情.当我看邮件时,我看到这个待定:
Class Args
Notify ["new_user_email", 8, "qrnq1kSQ"]
Run Code Online (Sandbox Code Playgroud)
我已经修改了gitlab.yml以获得正确的发件人地址:notify@mydomain.com
我想使用CGL或NSOpenGL创建一个OpenGL窗口而不使用XCode(使用命令行gcc编译).我正在开发跨平台的东西,如果可以的话,我想将代码分歧降到最低!我的代码库目前完全是C++.这是可能吗?我是OSX的新手,我没有触及目标C.我浏览了开发人员文档并抓住了一些示例文件.他们都使用xcode.我成功编译了源代码并与正确的框架链接,但整个应用程序包,xib和info.plist事情似乎有点过头了.