我基本上尝试使用javascript在我的html文档中创建一个40x40红格的div.
这是我的循环:
for(var i = 0; i < 40; i++) {
for(var j = 0; j< 40; j++) {
var div = document.createElement("div");
div.style.width = "25px";
div.style.height = "25px";
div.style.background = "red";
}
var jump = document.createElement("br");
document.getElementById("container").appendChild(jump);
document.getElementById("container").appendChild(div);
}
Run Code Online (Sandbox Code Playgroud)
问题是我似乎无法让它形成我创建的所有div的正方形.容器是1000 x 1000像素.谢谢
我在全球安装了快递,npm安装了我的快递应用程序,但智能或应用程序都没有工作(我在mac OS Yosemite上使用visual studio代码).
这是一个示例代码:
/// <reference path="typings/node/node.d.ts" />
/// <reference path="typings/express/express.d.ts" />
var express = require('express');
var app = express.createServer();
app.get('/', function (req, res) {
res.send('hi');
})
app.listen(8000);
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
Abeds-MacBook-Pro:myNode AZ$ node twitter.js
/Users/AZ/Desktop/myNode/twitter.js:5
var app = express.createServer();
^
TypeError: express.createServer is not a function
at Object.<anonymous> (/Users/AZ/Desktop/myNode/twitter.js:5:19)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:429:10)
at startup (node.js:139:18)
at node.js:999:3
Run Code Online (Sandbox Code Playgroud)
我研究了一下,发现createServer()已被弃用.我读到我需要在应用程序的某处更改版本.
注意:我使用纯粹的Node.js做了另一个应用程序,并且createServer()确实工作没有任何错误和intellisence.
编辑:在我的其他应用程序中,我使用了require('net').
我将我的代码修改为以下内容:
var express = require('express')
, …Run Code Online (Sandbox Code Playgroud) 这是我的ts组件:
import {Component, OnInit, Output, EventEmitter} from '@angular/core';
declare var google: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
title = 'Dashboard';
private map: any;
constructor() {
let brussels = new google.maps.LatLng(50.82, 4.35);
var mapOptions = {
zoom: 9,
center: brussels
};
this.map = new google.maps.Map(document.getElementById('googleMap'), mapOptions);
var marker = new google.maps.Marker({
position: brussels
});
//google.maps.event.addListener(marker, 'click', ( () => this.select.next("i was a map click")) )
marker.setMap(this.map);
}
ngOnInit(){
}
Run Code Online (Sandbox Code Playgroud)
这是我的HTML:
<h1>
{{title}} …Run Code Online (Sandbox Code Playgroud) 我正在尝试为双线图表添加工具提示.
但是,我使用scalePoint来绘制我的图表,而不是使用timeScale或scaleLinear.
我试图实现以下效果:https: //bl.ocks.org/mbostock/3902569
this.x = d3.scalePoint().range([ this.margin.left, this.width - this.margin.right ]);
this.xAxis = d3.axisBottom(this.x);
this.x.domain(
this.dataArray.map(d => {
return this.format(d[ 'year' ]);
}));
Run Code Online (Sandbox Code Playgroud)
这是我的鼠标悬停功能,
function mousemove() {
//d3.mouse(this)[ 0 ]
//x.invert
var x0 = d3.mouse(this)[ 0 ],
i = bisectDate(data, x0, 1),
d0 = data[ i - 1 ],
d1 = data[ i ],
d = x0 - d0.year > d1.year - x0 ? d1 : d0;
console.log(x0);
// focus.attr("transform", "translate(" + x(format(d.year)) + "," + y(d.housing_index_change) …Run Code Online (Sandbox Code Playgroud) 所以基本上我试图用 10^3 个完全随机数“填充”一个文件,所以我可以稍后将它们添加到二叉搜索树中。这是我目前使用的 populate 函数:
void populateFile(BinarySearchTree b) {
int random_integer;
srand( time( NULL ) );
std::ofstream myfile;
string line;
myfile.open ("output.txt");
myfile << "Writing this to a file: ";
for(int index=0; index<1000; index++)
{
random_integer = (rand()%1000)+1;
cout << random_integer << endl;
myfile << random_integer;
}
myfile.close();
int value;
ifstream file ("output.txt");
if (file.is_open())
{
while ( getline (file,line) )
{
value = std::stoi(line);
b.insert(value);
}
myfile.close();
}
else cout << "Unable to open file";
}
Run Code Online (Sandbox Code Playgroud)
但是我似乎无法写入文件,我只能在控制台上看到数字然后程序崩溃。
我的第二个问题如下:我想将这些相同的数字添加到二叉搜索树中。我已经有一个类和一个 dd …
我需要编写一个静态方法,它接受一个String参数并返回一个新的String,它通过用该字母的单个实例替换重复的相邻字母的每个实例而不使用正则表达式.例如,如果我输入"maaaakkee"作为a String,则返回"make".我已经尝试了以下代码,但它似乎没有显示最后一个字符.这是我的代码:
import java.util.Scanner;
public class undouble {
public static void main(String [] args){
Scanner console = new Scanner(System.in);
System.out.println("enter String: ");
String str = console.nextLine();
System.out.println(removeSpaces(str));
}
public static String removeSpaces(String str){
String ourString="";
int j = 0;
for (int i=0; i<str.length()-1 ; i++){
j = i+1;
if(str.charAt(i)!=str.charAt(j)){
ourString+=str.charAt(i);
}
}
return ourString;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试编译以下while循环,但是我继续在group.matcher("...")旁边的eclipse中得到一个红色标记,表示删除参数,所以我匹配组.
我得到的错误如下:
参数类型匹配器中的方法组(int)不适用于参数(String)
参数类型匹配器中的方法组(int)不适用于参数(String)
参数类型匹配器中的方法组(int)不适用于参数(String)
参数类型匹配器中的方法组(int)不适用于参数(String)
参数类型匹配器中的方法组(int)不适用于参数(String)
这是代码:
while (matcher.find()) {
if (matcher.group(TokenType.NUMBER.name()) != null) {
tokens.add(new Token(TokenType.NUMBER, matcher.group(TokenType.NUMBER.name())));
continue;
} else if (matcher.group(TokenType.BINARYOP.name()) != null) {
tokens.add(new Token(TokenType.BINARYOP, matcher.group(TokenType.BINARYOP.name())));
continue;
} else if (matcher.group(TokenType.WHITESPACE.name()) != null)
continue;
}
Run Code Online (Sandbox Code Playgroud) 我尝试使用不同的编辑器和IDE(netbeans和visual studio代码)以及不同的浏览器(firefox开发者版),但是,我似乎无法将css表应用于主html文件.样式表编辑器说没有样式表附加到html文件这里是html文件:
<!DOCTYPE html>
<html>
<head>
<title>The Animal Game</title>
<meta charset="utf-8"/>
<link href="animalgame.css" type="text/css" rel="stylsheet" />
<script src="animalgame.js" type="text/javascript"></script>
</head>
<body>
<h1>The Animal Game</h1>
<p>Think of an animal, then let me guess it!</p>
<div id="container">
<fieldset>
<legend>Questions</legend>
<p id="questions"></p>
</fieldset>
<fieldset id="answer">
<legend>Answer</legend>
<button id="yes">Yes</button>
<button id="no" >No</button>
</fieldset>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
CSS样式表:
body {
font: 12pt "Century Gothic", "Helvetica", "Arial", sans-serif;
}
button {
font-size: 20pt;
font-weight: bold;
margin: 15px auto;
}
#container{
margin: auto;
width: 520px;
}
fieldset …Run Code Online (Sandbox Code Playgroud) 我阅读了多个答案,指出如果一种语言不是上下文无关的,那么它的补充就是上下文无关的(如果我错了,请纠正我)。相反的情况是这样吗?上下文无关语言的补充是上下文无关的吗?
complexity-theory context-free-grammar formal-languages context-free-language
javascript ×4
css ×2
html ×2
java ×2
algorithm ×1
angular ×1
angularjs ×1
binary-tree ×1
c++ ×1
compilation ×1
d3.js ×1
d3v4 ×1
express ×1
google-maps ×1
node.js ×1
replace ×1
sorting ×1
string ×1