小编Nig*_*een的帖子

如何优化以下算法?

我们有以下算法:

while(a > b) {
     a -= c;
}
Run Code Online (Sandbox Code Playgroud)

给出a,b和c,b和c是常数,c> 0.

现在它在线性时间内工作.是否有可能加快速度,以对数或恒定时间工作?

algorithm optimization big-o

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

WKWebView错误:"在此服务器上找不到请求的URL"

在xcode 7 beta3中

当我使用object-c时没问题,但是当我使用swift时,我收到一个错误:"在这台服务器上找不到请求的URL",为什么?

这是代码:

#import "ViewController.h"
#import <WebKit/WebKit.h>


@interface ViewController ()

    @property(strong,nonatomic) WKWebView *webView;

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL *url = [NSURL URLWithString:@"http://www.apple.com"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    _webView = [[WKWebView alloc] initWithFrame:self.view.frame];
    [_webView loadRequest:request];
    [self.view addSubview:_webView];
}

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

@end 


swift:

import UIKit
import WebKit

class ViewController: UIViewController,WKNavigationDelegate {

    var webview: WKWebView?

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    override …
Run Code Online (Sandbox Code Playgroud)

ios swift wkwebview xcode7-beta3

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

遗传算法中的锦标赛选择

我为遗传算法中的锦标赛选择做了这个程序:

从人口中选择k个随机个体,并从这些k个体中选择两个最佳个体作为父母.

这是对的吗?

genetic-algorithm

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

我怎样才能不重复背景?

我想为javascript制作无重复图片(背景).

e.target.style.backgroundImage = "url(sozai/a.jpg)";
Run Code Online (Sandbox Code Playgroud)

在这种情况下,a.jpg将反复显示为背景,但我希望不再重复.

另外,我想改变图片的透明度.

javascript

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

在python字典中操作和打印项目

我有以下代码:

ex_dict={1:"how",3:"do you",7:"dotoday"}
for key in ex_dict:
    string= key," and this is ", ex_dict[key]
    print (string)
Run Code Online (Sandbox Code Playgroud)

输出是:

(1, ' and this is ', 'how')
(3, ' and this is ', 'do you')
(7, ' and this is ', 'dotoday')
Run Code Online (Sandbox Code Playgroud)

我的预期输出:

1 and this is how
3 and this is do you
7 and this is dotoday
Run Code Online (Sandbox Code Playgroud)

我似乎无法弄清楚如何摆脱输出中的字典格式.

python python-2.7

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

如果屏幕上有足够的空间,请将桌子并排放置

我有两个HTML表格,理想情况下可以并排放在屏幕上.宽屏显示器将应对这种精细,但桌子太宽,无法在大多数老式显示器上并排.因此,如果分辨率足够高,我想使用css(或者甚至只是HTML,如果可能的话)并排放置表格.

这通常会自动与图像一起使用,但有没有办法为表格执行此操作?

html css html-table

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

使用int(str)

我想知道是否有更简单的方法来做到这一点?

if '0' in next or '1' in next or '2' in next or '3' in next or '4' in next or '5' in next or '6' in next or '7' in next or '8' in next or '9' in next:
        how_much = int(next)
Run Code Online (Sandbox Code Playgroud)

python int numbers python-2.7

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

如何设置<table>标签内的<td>项?

我使用jsp和css作为样式的<td>内部<table>标记.我想要如下代码:

在此输入图像描述

但现在我得到了:

在此输入图像描述

#bengalistorycontainer{
	width:100%;
	
}
table.my-special-table {
  width: 10px;
height: 10px; 

border: 1px rgb(89,89,89) solid;

}
Run Code Online (Sandbox Code Playgroud)
 
  <table class="my-special-table">
<tr>
            <c:forEach begin="1" end="${classfile}" var="i"varStatus="loop">
                <c:choose>
                    <c:when test="${classfile eq i}">
                        <td>${1}   </div></td>
                    </c:when>
                    <c:otherwise>
                        <td><a href="#">${2}</a></td>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        
   <c:if test="${totalpagenumber != 1}">
     <td>  <a href="#">next</a> </td>
    </c:if>
     
Run Code Online (Sandbox Code Playgroud)

的jsfiddle

我究竟做错了什么?

html css

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