小编use*_*872的帖子

创建一个ofstreams矢量

我正在尝试创建一个ofstreams矢量..

vector<ofstream> streams;
for (int i = 0; i < numStreams; i++){
  ofstream out;
  string fileName = "text" + to_string(i) + ".txt";
  output.open(fileName.c_str());
  streams.push_back(out);
}
Run Code Online (Sandbox Code Playgroud)

这段代码不会编译..特别是我尝试将ofstream添加到vector的最后一行产生错误.我在俯瞰什么?

c++ ofstream

9
推荐指数
2
解决办法
3677
查看次数

将学生分为两组的图算法

我正在努力创建一种有效的算法,可以确定一组学生是否可以分为两组.

请注意,(X,Y)学生X必须与学生一起提供Y一些类型的约束,以及(A,B)学生A不能与学生一起使用的类型约束B.并非每个学生都对他有约束,有些学生有多种限制.

我认为是一个图形,其中每个学生都是一个节点,然后两个节点通过边连接,如果学生可以在同一个组(例如,它们要么有,他们必须要装配在一起和/或不具有约束约束他们不能在一起).但是,一旦我构造了这个图形表示,我不确定我可以应用什么算法来解决(或证明,给定一组约束这是不可能的).

任何建议表示赞赏?谢谢!

algorithm graph breadth-first-search depth

2
推荐指数
1
解决办法
1476
查看次数

为什么使用Autolayout/Constraints而不是frame和layoutSubviews?

我为我的应用程序的启动屏幕实现了一个视图控制器,如下所示.我决定使用框架而不是autolayout,我想知道是否有任何理由在这里使用autolayout/constraints.

我不允许在我的应用程序上轮换,所以我看不出我会从约束中获得什么好处,因为我不喜欢使用界面构建器,我认为代码更清晰/更容易创建和布局框架.

我感谢任何输入 - 请找到下面的代码.

#import "LaunchViewController.h"
#import "RegisterTableViewController.h"
#import <QuartzCore/QuartzCore.h>

@interface LaunchViewController ()

@property (nonatomic) UILabel *appLabel;
@property (nonatomic) UIButton *signUpButton;
@property (nonatomic) UIButton *loginButton;

@end

@implementation LaunchViewController

#pragma mark - UIViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor standardBlackColor];
    [self layoutViews];
}

- (void)viewDidAppear {
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UIView

- (void)layoutViews
{
    self.appLabel.frame = [self _appLabelFrame];
    self.loginButton.frame = [self …
Run Code Online (Sandbox Code Playgroud)

frame ios autolayout

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