首先很抱歉,因为我的英语可能不好。我想使用变量来索引数组中的元素或使用相同的变量来索引所有元素。例如:
...
var1="1"
var2="*"
array=(one two three for five)
for elem in ${array[$var1]}
do
echo $elem
done
Run Code Online (Sandbox Code Playgroud)
当我使用var1在${array[$var1]} 中建立索引时它可以正常工作,但是如果我使用var2不能正常工作,我会收到此错误:
./ed.sh line XXX *: syntax error: operand expected (error token is "*")
Run Code Online (Sandbox Code Playgroud)
我很确定该错误与 * 通配符扩展有关,但我没有找到可以帮助我解决此问题的答案。那么,我该怎么做呢?
I want to write NodeJS code for solving problems like ICPC. The following is an example using a template of www.hackerrank.com for submitting in JavaScript:
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});
function readLine() {
return input_stdin_array[input_currentline++];
}
/////////////// ignore above this line ////////////////////
function main() {
var s = readLine();
s = s.split(",");
s = …
Run Code Online (Sandbox Code Playgroud) 所以用户需要先输入字数,然后自己输入字数。我应该如何阅读这些单词并将它们放入向量中?
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
int main(){
int n;
vector<string>words;
string word;
cin >> n;
for (int i = 1; i <= n; i++){
cin >> word;
words.push_back(word);
}
cout << words;
}
Run Code Online (Sandbox Code Playgroud)
我试过这个,但是当我运行它时,它给了我一个错误,说“不匹配 'operator<<'”,这与 cout << words; 你们中的任何人都可以解释这个错误吗?
我是亚马逊网络服务的新手.我创建了一个ec2实例,并希望在其上安装Java.我已下载rpm文件但无法执行它.下面是root下的文件夹/文件列表.
root@ip-172-31-6-12:~# ls
install.sh jdk1.8_1.8.0171-1_amd64.deb node_modules node-v8.11.3.tar.gz
jdk-10.0.1 jdk-8u171-linux-x64.rpm node-v8.11.3 survey
Run Code Online (Sandbox Code Playgroud)
当我跑步的时候
dpkg -i jdk1.8_1.8.0171-1_amd64.deb
Run Code Online (Sandbox Code Playgroud)
我收到了这条消息.
dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
dpkg: error: 2 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
Run Code Online (Sandbox Code Playgroud)
请让我知道,我在这里缺少什么.
amazon-ec2 ×1
arrays ×1
bash ×1
c++ ×1
c++17 ×1
indexing ×1
java ×1
javascript ×1
node.js ×1
ubuntu ×1